Search in sources :

Example 1 with ExprCodeGenerator

use of org.apache.flink.table.planner.codegen.ExprCodeGenerator in project flink by apache.

the class StreamExecTemporalJoin method getJoinOperator.

private TwoInputStreamOperator<RowData, RowData, RowData> getJoinOperator(ExecNodeConfig config, RowType leftInputType, RowType rightInputType) {
    // input must not be nullable, because the runtime join function will make sure
    // the code-generated function won't process null inputs
    final CodeGeneratorContext ctx = new CodeGeneratorContext(config.getTableConfig());
    final ExprCodeGenerator exprGenerator = new ExprCodeGenerator(ctx, false).bindInput(leftInputType, CodeGenUtils.DEFAULT_INPUT1_TERM(), JavaScalaConversionUtil.toScala(Optional.empty())).bindSecondInput(rightInputType, CodeGenUtils.DEFAULT_INPUT2_TERM(), JavaScalaConversionUtil.toScala(Optional.empty()));
    String body = "return true;";
    if (joinSpec.getNonEquiCondition().isPresent()) {
        final GeneratedExpression condition = exprGenerator.generateExpression(joinSpec.getNonEquiCondition().get());
        body = String.format("%s\nreturn %s;", condition.code(), condition.resultTerm());
    }
    GeneratedJoinCondition generatedJoinCondition = FunctionCodeGenerator.generateJoinCondition(ctx, "ConditionFunction", body, CodeGenUtils.DEFAULT_INPUT1_TERM(), CodeGenUtils.DEFAULT_INPUT2_TERM());
    return createJoinOperator(config, leftInputType, rightInputType, generatedJoinCondition);
}
Also used : GeneratedJoinCondition(org.apache.flink.table.runtime.generated.GeneratedJoinCondition) CodeGeneratorContext(org.apache.flink.table.planner.codegen.CodeGeneratorContext) GeneratedExpression(org.apache.flink.table.planner.codegen.GeneratedExpression) ExprCodeGenerator(org.apache.flink.table.planner.codegen.ExprCodeGenerator)

Aggregations

CodeGeneratorContext (org.apache.flink.table.planner.codegen.CodeGeneratorContext)1 ExprCodeGenerator (org.apache.flink.table.planner.codegen.ExprCodeGenerator)1 GeneratedExpression (org.apache.flink.table.planner.codegen.GeneratedExpression)1 GeneratedJoinCondition (org.apache.flink.table.runtime.generated.GeneratedJoinCondition)1