use of org.apache.flink.table.planner.plan.nodes.physical.stream.StreamPhysicalCalc in project flink by apache.
the class PushFilterPastChangelogNormalizeRule method transformWithRemainingPredicates.
/**
* Transforms the {@link RelOptRuleCall} to use {@param changelogNormalize} as the new input to
* a {@link StreamPhysicalCalc} which uses {@param predicates} for the condition.
*/
private void transformWithRemainingPredicates(RelOptRuleCall call, StreamPhysicalChangelogNormalize changelogNormalize, List<RexNode> predicates) {
final StreamPhysicalCalc calc = call.rel(0);
final RelBuilder relBuilder = call.builder();
final StreamPhysicalCalc newCalc = projectIdentityWithConditions(relBuilder, changelogNormalize, predicates);
final StreamPhysicalCalc newProjectedCalc = projectWith(relBuilder, calc, newCalc);
if (newProjectedCalc.getProgram().isTrivial()) {
call.transformTo(changelogNormalize);
} else {
call.transformTo(newProjectedCalc);
}
}
use of org.apache.flink.table.planner.plan.nodes.physical.stream.StreamPhysicalCalc in project flink by apache.
the class PushFilterPastChangelogNormalizeRule method projectWith.
/**
* Returns a {@link StreamPhysicalCalc} which is a copy of {@param calc}, but with the
* projections applied from {@param projectFromCalc}.
*/
private StreamPhysicalCalc projectWith(RelBuilder relBuilder, StreamPhysicalCalc projectFromCalc, StreamPhysicalCalc calc) {
final RexProgramBuilder programBuilder = new RexProgramBuilder(calc.getRowType(), relBuilder.getRexBuilder());
if (calc.getProgram().getCondition() != null) {
programBuilder.addCondition(calc.getProgram().expandLocalRef(calc.getProgram().getCondition()));
}
for (Pair<RexLocalRef, String> projectRef : projectFromCalc.getProgram().getNamedProjects()) {
final RexNode project = projectFromCalc.getProgram().expandLocalRef(projectRef.left);
programBuilder.addProject(project, projectRef.right);
}
final RexProgram newProgram = programBuilder.getProgram();
return (StreamPhysicalCalc) calc.copy(calc.getTraitSet(), calc.getInput(), newProgram);
}
Aggregations