Search in sources :

Example 1 with FunctionCatalog

use of org.apache.flink.table.catalog.FunctionCatalog in project flink by apache.

the class JsonSerdeTestUtil method configuredSerdeContext.

static SerdeContext configuredSerdeContext(CatalogManager catalogManager, TableConfig tableConfig) {
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    final ModuleManager moduleManager = new ModuleManager();
    final FunctionCatalog functionCatalog = new FunctionCatalog(tableConfig, catalogManager, moduleManager);
    final PlannerContext plannerContext = new PlannerContext(false, tableConfig, moduleManager, functionCatalog, catalogManager, asRootSchema(new CatalogManagerCalciteSchema(catalogManager, true)), Collections.emptyList());
    return new SerdeContext(new ParserImpl(null, null, plannerContext::createCalciteParser, null), plannerContext.getFlinkContext(), classLoader, FlinkTypeFactory.INSTANCE(), plannerContext.createFrameworkConfig().getOperatorTable());
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) PlannerContext(org.apache.flink.table.planner.delegation.PlannerContext) ParserImpl(org.apache.flink.table.planner.delegation.ParserImpl) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManagerCalciteSchema(org.apache.flink.table.planner.catalog.CatalogManagerCalciteSchema)

Example 2 with FunctionCatalog

use of org.apache.flink.table.catalog.FunctionCatalog in project flink by apache.

the class SessionContext method create.

// --------------------------------------------------------------------------------------------
// Helper method to create
// --------------------------------------------------------------------------------------------
public static SessionContext create(DefaultContext defaultContext, String sessionId) {
    // --------------------------------------------------------------------------------------------------------------
    // Init config
    // --------------------------------------------------------------------------------------------------------------
    Configuration configuration = defaultContext.getFlinkConfig().clone();
    // --------------------------------------------------------------------------------------------------------------
    // Init classloader
    // --------------------------------------------------------------------------------------------------------------
    URLClassLoader classLoader = ClientUtils.buildUserCodeClassLoader(defaultContext.getDependencies(), Collections.emptyList(), SessionContext.class.getClassLoader(), configuration);
    // --------------------------------------------------------------------------------------------------------------
    // Init session state
    // --------------------------------------------------------------------------------------------------------------
    ModuleManager moduleManager = new ModuleManager();
    final EnvironmentSettings settings = EnvironmentSettings.fromConfiguration(configuration);
    CatalogManager catalogManager = CatalogManager.newBuilder().classLoader(classLoader).config(configuration).defaultCatalog(settings.getBuiltInCatalogName(), new GenericInMemoryCatalog(settings.getBuiltInCatalogName(), settings.getBuiltInDatabaseName())).build();
    FunctionCatalog functionCatalog = new FunctionCatalog(configuration, catalogManager, moduleManager);
    SessionState sessionState = new SessionState(catalogManager, moduleManager, functionCatalog);
    // --------------------------------------------------------------------------------------------------------------
    // Init ExecutionContext
    // --------------------------------------------------------------------------------------------------------------
    ExecutionContext executionContext = new ExecutionContext(configuration, classLoader, sessionState);
    return new SessionContext(defaultContext, sessionId, configuration, classLoader, sessionState, executionContext);
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) EnvironmentSettings(org.apache.flink.table.api.EnvironmentSettings) Configuration(org.apache.flink.configuration.Configuration) URLClassLoader(java.net.URLClassLoader) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManager(org.apache.flink.table.catalog.CatalogManager) GenericInMemoryCatalog(org.apache.flink.table.catalog.GenericInMemoryCatalog)

Example 3 with FunctionCatalog

use of org.apache.flink.table.catalog.FunctionCatalog in project flink by apache.

the class StreamTableEnvironmentImplTest method getStreamTableEnvironment.

private StreamTableEnvironmentImpl getStreamTableEnvironment(StreamExecutionEnvironment env, DataStreamSource<Integer> elements) {
    TableConfig tableConfig = new TableConfig();
    CatalogManager catalogManager = CatalogManagerMocks.createEmptyCatalogManager();
    ModuleManager moduleManager = new ModuleManager();
    return new StreamTableEnvironmentImpl(catalogManager, moduleManager, new FunctionCatalog(tableConfig, catalogManager, moduleManager), tableConfig, env, new TestPlanner(elements.getTransformation()), new ExecutorMock(), true, this.getClass().getClassLoader());
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) TableConfig(org.apache.flink.table.api.TableConfig) ExecutorMock(org.apache.flink.table.utils.ExecutorMock) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManager(org.apache.flink.table.catalog.CatalogManager)

Example 4 with FunctionCatalog

use of org.apache.flink.table.catalog.FunctionCatalog in project zeppelin by apache.

the class TableEnvFactory method createJavaFlinkStreamTableEnvironment.

public TableEnvironment createJavaFlinkStreamTableEnvironment(EnvironmentSettings settings, ClassLoader classLoader) {
    try {
        ImmutablePair<Object, Object> pair = flinkShims.createPlannerAndExecutor(classLoader, settings, senv.getJavaEnv(), oldPlannerBatchTableConfig, functionCatalog, catalogManager);
        Planner planner = (Planner) pair.left;
        Executor executor = (Executor) pair.right;
        Class clazz = Class.forName("org.apache.flink.table.api.bridge.java.internal.StreamTableEnvironmentImpl");
        try {
            Constructor constructor = clazz.getConstructor(CatalogManager.class, ModuleManager.class, FunctionCatalog.class, TableConfig.class, org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.class, Planner.class, Executor.class, boolean.class);
            return (TableEnvironment) constructor.newInstance(oldPlannerCatalogManager, moduleManager, oldPlannerFunctionCatalog, oldPlannerStreamTableConfig, senv.getJavaEnv(), planner, executor, settings.isStreamingMode());
        } catch (NoSuchMethodException e) {
            // Flink 1.11.1 change the constructor signature, FLINK-18419
            Constructor constructor = clazz.getConstructor(CatalogManager.class, ModuleManager.class, FunctionCatalog.class, TableConfig.class, org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.class, Planner.class, Executor.class, boolean.class, ClassLoader.class);
            return (TableEnvironment) constructor.newInstance(oldPlannerCatalogManager, moduleManager, oldPlannerFunctionCatalog, oldPlannerStreamTableConfig, senv.getJavaEnv(), planner, executor, settings.isStreamingMode(), classLoader);
        }
    } catch (Exception e) {
        throw new TableException("Fail to createJavaFlinkStreamTableEnvironment", e);
    }
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) TableException(org.apache.flink.table.api.TableException) Constructor(java.lang.reflect.Constructor) TableEnvironment(org.apache.flink.table.api.TableEnvironment) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManager(org.apache.flink.table.catalog.CatalogManager) TableException(org.apache.flink.table.api.TableException) Executor(org.apache.flink.table.delegation.Executor) TableConfig(org.apache.flink.table.api.TableConfig) Planner(org.apache.flink.table.delegation.Planner) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Example 5 with FunctionCatalog

use of org.apache.flink.table.catalog.FunctionCatalog in project zeppelin by apache.

the class TableEnvFactory method createScalaBlinkStreamTableEnvironment.

public TableEnvironment createScalaBlinkStreamTableEnvironment(EnvironmentSettings settings, ClassLoader classLoader) {
    try {
        ImmutablePair<Object, Object> pair = flinkShims.createPlannerAndExecutor(classLoader, settings, senv.getJavaEnv(), streamTableConfig, functionCatalog, catalogManager);
        Planner planner = (Planner) pair.left;
        Executor executor = (Executor) pair.right;
        Class clazz = Class.forName("org.apache.flink.table.api.bridge.scala.internal.StreamTableEnvironmentImpl");
        try {
            Constructor constructor = clazz.getConstructor(CatalogManager.class, ModuleManager.class, FunctionCatalog.class, TableConfig.class, org.apache.flink.streaming.api.scala.StreamExecutionEnvironment.class, Planner.class, Executor.class, boolean.class);
            return (TableEnvironment) constructor.newInstance(catalogManager, moduleManager, functionCatalog, streamTableConfig, senv, planner, executor, settings.isStreamingMode());
        } catch (NoSuchMethodException e) {
            // Flink 1.11.1 change the constructor signature, FLINK-18419
            Constructor constructor = clazz.getConstructor(CatalogManager.class, ModuleManager.class, FunctionCatalog.class, TableConfig.class, org.apache.flink.streaming.api.scala.StreamExecutionEnvironment.class, Planner.class, Executor.class, boolean.class, ClassLoader.class);
            return (TableEnvironment) constructor.newInstance(catalogManager, moduleManager, functionCatalog, streamTableConfig, senv, planner, executor, settings.isStreamingMode(), classLoader);
        }
    } catch (Exception e) {
        throw new TableException("Fail to createScalaBlinkStreamTableEnvironment", e);
    }
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) TableException(org.apache.flink.table.api.TableException) Constructor(java.lang.reflect.Constructor) TableEnvironment(org.apache.flink.table.api.TableEnvironment) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManager(org.apache.flink.table.catalog.CatalogManager) TableException(org.apache.flink.table.api.TableException) Executor(org.apache.flink.table.delegation.Executor) TableConfig(org.apache.flink.table.api.TableConfig) Planner(org.apache.flink.table.delegation.Planner) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Aggregations

FunctionCatalog (org.apache.flink.table.catalog.FunctionCatalog)11 ModuleManager (org.apache.flink.table.module.ModuleManager)11 CatalogManager (org.apache.flink.table.catalog.CatalogManager)10 TableConfig (org.apache.flink.table.api.TableConfig)8 Executor (org.apache.flink.table.delegation.Executor)7 Planner (org.apache.flink.table.delegation.Planner)7 Constructor (java.lang.reflect.Constructor)5 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)5 TableEnvironment (org.apache.flink.table.api.TableEnvironment)5 TableException (org.apache.flink.table.api.TableException)5 GenericInMemoryCatalog (org.apache.flink.table.catalog.GenericInMemoryCatalog)4 URLClassLoader (java.net.URLClassLoader)1 RexBuilder (org.apache.calcite.rex.RexBuilder)1 Configuration (org.apache.flink.configuration.Configuration)1 ObjectReader (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader)1 ObjectWriter (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter)1 EnvironmentSettings (org.apache.flink.table.api.EnvironmentSettings)1 AbstractStreamTableEnvironmentImpl (org.apache.flink.table.api.bridge.internal.AbstractStreamTableEnvironmentImpl)1 ExecutorFactory (org.apache.flink.table.delegation.ExecutorFactory)1 FlinkContext (org.apache.flink.table.planner.calcite.FlinkContext)1