Search in sources :

Example 1 with TableFunctionCollector

use of org.apache.flink.table.runtime.collector.TableFunctionCollector in project flink by apache.

the class CommonExecLookupJoin method createSyncLookupJoin.

private StreamOperatorFactory<RowData> createSyncLookupJoin(RelOptTable temporalTable, ExecNodeConfig config, Map<Integer, LookupJoinUtil.LookupKey> allLookupKeys, TableFunction<?> syncLookupFunction, RelBuilder relBuilder, RowType inputRowType, RowType tableSourceRowType, RowType resultRowType, boolean isLeftOuterJoin, boolean isObjectReuseEnabled) {
    DataTypeFactory dataTypeFactory = ShortcutUtils.unwrapContext(relBuilder).getCatalogManager().getDataTypeFactory();
    int[] orderedLookupKeys = LookupJoinUtil.getOrderedLookupKeys(allLookupKeys.keySet());
    GeneratedFunction<FlatMapFunction<RowData, RowData>> generatedFetcher = LookupJoinCodeGenerator.generateSyncLookupFunction(config.getTableConfig(), dataTypeFactory, inputRowType, tableSourceRowType, resultRowType, allLookupKeys, orderedLookupKeys, syncLookupFunction, StringUtils.join(temporalTable.getQualifiedName(), "."), isObjectReuseEnabled);
    RowType rightRowType = Optional.ofNullable(temporalTableOutputType).map(FlinkTypeFactory::toLogicalRowType).orElse(tableSourceRowType);
    CodeGeneratorContext ctx = new CodeGeneratorContext(config.getTableConfig());
    GeneratedCollector<TableFunctionCollector<RowData>> generatedCollector = LookupJoinCodeGenerator.generateCollector(ctx, inputRowType, rightRowType, resultRowType, JavaScalaConversionUtil.toScala(Optional.ofNullable(joinCondition)), JavaScalaConversionUtil.toScala(Optional.empty()), true);
    ProcessFunction<RowData, RowData> processFunc;
    if (existCalcOnTemporalTable) {
        // a projection or filter after table source scan
        GeneratedFunction<FlatMapFunction<RowData, RowData>> generatedCalc = LookupJoinCodeGenerator.generateCalcMapFunction(config.getTableConfig(), JavaScalaConversionUtil.toScala(projectionOnTemporalTable), filterOnTemporalTable, temporalTableOutputType, tableSourceRowType);
        processFunc = new LookupJoinWithCalcRunner(generatedFetcher, generatedCalc, generatedCollector, isLeftOuterJoin, rightRowType.getFieldCount());
    } else {
        // right type is the same as table source row type, because no calc after temporal table
        processFunc = new LookupJoinRunner(generatedFetcher, generatedCollector, isLeftOuterJoin, rightRowType.getFieldCount());
    }
    return SimpleOperatorFactory.of(new ProcessOperator<>(processFunc));
}
Also used : CodeGeneratorContext(org.apache.flink.table.planner.codegen.CodeGeneratorContext) RowType(org.apache.flink.table.types.logical.RowType) DataTypeFactory(org.apache.flink.table.catalog.DataTypeFactory) TableFunctionCollector(org.apache.flink.table.runtime.collector.TableFunctionCollector) AsyncLookupJoinRunner(org.apache.flink.table.runtime.operators.join.lookup.AsyncLookupJoinRunner) LookupJoinRunner(org.apache.flink.table.runtime.operators.join.lookup.LookupJoinRunner) RowData(org.apache.flink.table.data.RowData) FlatMapFunction(org.apache.flink.api.common.functions.FlatMapFunction) LookupJoinWithCalcRunner(org.apache.flink.table.runtime.operators.join.lookup.LookupJoinWithCalcRunner) AsyncLookupJoinWithCalcRunner(org.apache.flink.table.runtime.operators.join.lookup.AsyncLookupJoinWithCalcRunner)

Aggregations

FlatMapFunction (org.apache.flink.api.common.functions.FlatMapFunction)1 DataTypeFactory (org.apache.flink.table.catalog.DataTypeFactory)1 RowData (org.apache.flink.table.data.RowData)1 CodeGeneratorContext (org.apache.flink.table.planner.codegen.CodeGeneratorContext)1 TableFunctionCollector (org.apache.flink.table.runtime.collector.TableFunctionCollector)1 AsyncLookupJoinRunner (org.apache.flink.table.runtime.operators.join.lookup.AsyncLookupJoinRunner)1 AsyncLookupJoinWithCalcRunner (org.apache.flink.table.runtime.operators.join.lookup.AsyncLookupJoinWithCalcRunner)1 LookupJoinRunner (org.apache.flink.table.runtime.operators.join.lookup.LookupJoinRunner)1 LookupJoinWithCalcRunner (org.apache.flink.table.runtime.operators.join.lookup.LookupJoinWithCalcRunner)1 RowType (org.apache.flink.table.types.logical.RowType)1