Search in sources :

Example 26 with TableConfig

use of org.apache.flink.table.api.TableConfig in project flink by apache.

the class StreamArrowPythonRowTimeBoundedRowsOperatorTest method getTestOperator.

@Override
public AbstractArrowPythonAggregateFunctionOperator getTestOperator(Configuration config, PythonFunctionInfo[] pandasAggregateFunctions, RowType inputType, RowType outputType, int[] groupingSet, int[] udafInputOffsets) {
    RowType udfInputType = (RowType) Projection.of(udafInputOffsets).project(inputType);
    RowType udfOutputType = (RowType) Projection.range(inputType.getFieldCount(), outputType.getFieldCount()).project(outputType);
    return new PassThroughStreamArrowPythonRowTimeBoundedRowsOperator(config, pandasAggregateFunctions, inputType, udfInputType, udfOutputType, 3, 1, ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "UdafInputProjection", inputType, udfInputType, udafInputOffsets));
}
Also used : RowType(org.apache.flink.table.types.logical.RowType) TableConfig(org.apache.flink.table.api.TableConfig)

Example 27 with TableConfig

use of org.apache.flink.table.api.TableConfig in project flink by apache.

the class PythonScalarFunctionOperatorTest method getTestOperator.

@Override
public AbstractPythonScalarFunctionOperator getTestOperator(Configuration config, PythonFunctionInfo[] scalarFunctions, RowType inputType, RowType outputType, int[] udfInputOffsets, int[] forwardedFields) {
    final RowType udfInputType = (RowType) Projection.of(udfInputOffsets).project(inputType);
    final RowType forwardedFieldType = (RowType) Projection.of(forwardedFields).project(inputType);
    final RowType udfOutputType = (RowType) Projection.range(forwardedFields.length, outputType.getFieldCount()).project(outputType);
    return new PassThroughPythonScalarFunctionOperator(config, scalarFunctions, inputType, udfInputType, udfOutputType, ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "UdfInputProjection", inputType, udfInputType, udfInputOffsets), ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "ForwardedFieldProjection", inputType, forwardedFieldType, forwardedFields));
}
Also used : RowType(org.apache.flink.table.types.logical.RowType) TableConfig(org.apache.flink.table.api.TableConfig)

Example 28 with TableConfig

use of org.apache.flink.table.api.TableConfig in project flink by apache.

the class ArrowPythonScalarFunctionOperatorTest method getTestOperator.

@Override
public ArrowPythonScalarFunctionOperator getTestOperator(Configuration config, PythonFunctionInfo[] scalarFunctions, RowType inputType, RowType outputType, int[] udfInputOffsets, int[] forwardedFields) {
    final RowType udfInputType = (RowType) Projection.of(udfInputOffsets).project(inputType);
    final RowType forwardedFieldType = (RowType) Projection.of(forwardedFields).project(inputType);
    final RowType udfOutputType = (RowType) Projection.range(forwardedFields.length, outputType.getFieldCount()).project(outputType);
    return new PassThroughRowDataArrowPythonScalarFunctionOperator(config, scalarFunctions, inputType, udfInputType, udfOutputType, ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "UdfInputProjection", inputType, udfInputType, udfInputOffsets), ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "ForwardedFieldProjection", inputType, forwardedFieldType, forwardedFields));
}
Also used : RowType(org.apache.flink.table.types.logical.RowType) TableConfig(org.apache.flink.table.api.TableConfig)

Example 29 with TableConfig

use of org.apache.flink.table.api.TableConfig 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 30 with TableConfig

use of org.apache.flink.table.api.TableConfig 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

TableConfig (org.apache.flink.table.api.TableConfig)41 RowType (org.apache.flink.table.types.logical.RowType)19 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 RexNode (org.apache.calcite.rex.RexNode)6 CatalogManager (org.apache.flink.table.catalog.CatalogManager)6 IOException (java.io.IOException)5 OutputStream (java.io.OutputStream)5 PrintStream (java.io.PrintStream)5 Arrays (java.util.Arrays)5 Collections (java.util.Collections)5 List (java.util.List)5 RexBuilder (org.apache.calcite.rex.RexBuilder)5 RexInputRef (org.apache.calcite.rex.RexInputRef)5 Table (org.apache.flink.table.api.Table)5 FlinkTypeFactory (org.apache.flink.table.planner.calcite.FlinkTypeFactory)5 IntType (org.apache.flink.table.types.logical.IntType)5 Row (org.apache.flink.types.Row)5 Random (java.util.Random)4 Consumer (java.util.function.Consumer)4