Search in sources :

Example 6 with ModuleManager

use of org.apache.flink.table.module.ModuleManager 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)

Example 7 with ModuleManager

use of org.apache.flink.table.module.ModuleManager in project flink by apache.

the class FunctionCatalogTest method init.

@Before
public void init() {
    catalog = new GenericInMemoryCatalog(DEFAULT_CATALOG, DEFAULT_DATABASE);
    moduleManager = new ModuleManager();
    functionCatalog = new FunctionCatalog(TableConfig.getDefault(), CatalogManagerMocks.preparedCatalogManager().defaultCatalog(DEFAULT_CATALOG, catalog).build(), moduleManager);
}
Also used : ModuleManager(org.apache.flink.table.module.ModuleManager) Before(org.junit.Before)

Example 8 with ModuleManager

use of org.apache.flink.table.module.ModuleManager in project flink by apache.

the class FunctionCatalogTest method testGetBuiltInFunctions.

@Test
public void testGetBuiltInFunctions() {
    Set<String> actual = new HashSet<>();
    Collections.addAll(actual, functionCatalog.getFunctions());
    Set<String> expected = new ModuleManager().listFunctions();
    assertThat(actual.containsAll(expected)).isTrue();
}
Also used : ModuleManager(org.apache.flink.table.module.ModuleManager) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with ModuleManager

use of org.apache.flink.table.module.ModuleManager in project flink by apache.

the class TableEnvironmentMock method getInstance.

private static TableEnvironmentMock getInstance(boolean isStreamingMode) {
    final TableConfig tableConfig = createTableConfig();
    final CatalogManager catalogManager = CatalogManagerMocks.createEmptyCatalogManager();
    final ModuleManager moduleManager = new ModuleManager();
    return new TableEnvironmentMock(catalogManager, moduleManager, tableConfig, createExecutor(), createFunctionCatalog(tableConfig, catalogManager, moduleManager), createPlanner(), isStreamingMode);
}
Also used : TableConfig(org.apache.flink.table.api.TableConfig) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManager(org.apache.flink.table.catalog.CatalogManager)

Example 10 with ModuleManager

use of org.apache.flink.table.module.ModuleManager in project flink by apache.

the class TableEnvironmentImpl method create.

private static TableEnvironmentImpl create(EnvironmentSettings settings, Configuration configuration) {
    // temporary solution until FLINK-15635 is fixed
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    // use configuration to init table config
    final TableConfig tableConfig = new TableConfig();
    tableConfig.addConfiguration(configuration);
    final ModuleManager moduleManager = new ModuleManager();
    final CatalogManager catalogManager = CatalogManager.newBuilder().classLoader(classLoader).config(tableConfig.getConfiguration()).defaultCatalog(settings.getBuiltInCatalogName(), new GenericInMemoryCatalog(settings.getBuiltInCatalogName(), settings.getBuiltInDatabaseName())).build();
    final FunctionCatalog functionCatalog = new FunctionCatalog(tableConfig, catalogManager, moduleManager);
    final ExecutorFactory executorFactory = FactoryUtil.discoverFactory(classLoader, ExecutorFactory.class, settings.getExecutor());
    final Executor executor = executorFactory.create(configuration);
    final Planner planner = PlannerFactoryUtil.createPlanner(settings.getPlanner(), executor, tableConfig, moduleManager, catalogManager, functionCatalog);
    return new TableEnvironmentImpl(catalogManager, moduleManager, tableConfig, executor, functionCatalog, planner, settings.isStreamingMode(), classLoader);
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) Executor(org.apache.flink.table.delegation.Executor) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) TableConfig(org.apache.flink.table.api.TableConfig) Planner(org.apache.flink.table.delegation.Planner) ModuleManager(org.apache.flink.table.module.ModuleManager) CatalogManager(org.apache.flink.table.catalog.CatalogManager) GenericInMemoryCatalog(org.apache.flink.table.catalog.GenericInMemoryCatalog)

Aggregations

ModuleManager (org.apache.flink.table.module.ModuleManager)16 CatalogManager (org.apache.flink.table.catalog.CatalogManager)11 FunctionCatalog (org.apache.flink.table.catalog.FunctionCatalog)11 TableConfig (org.apache.flink.table.api.TableConfig)9 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 Test (org.junit.Test)4 ObjectReader (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader)3 ObjectWriter (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter)3 FlinkContextImpl (org.apache.flink.table.planner.calcite.FlinkContextImpl)3 RexBuilder (org.apache.calcite.rex.RexBuilder)2 URLClassLoader (java.net.URLClassLoader)1 HashSet (java.util.HashSet)1 RexWindowBound (org.apache.calcite.rex.RexWindowBound)1 Configuration (org.apache.flink.configuration.Configuration)1