use of org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalRank in project flink by apache.
the class RedundantRankNumberColumnRemoveRule method matches.
@Override
public boolean matches(RelOptRuleCall call) {
FlinkLogicalCalc calc = call.rel(0);
ImmutableBitSet usedFields = getUsedFields(calc.getProgram());
FlinkLogicalRank rank = call.rel(1);
return rank.outputRankNumber() && !usedFields.get(rank.getRowType().getFieldCount() - 1);
}
use of org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalRank in project flink by apache.
the class RedundantRankNumberColumnRemoveRule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
FlinkLogicalCalc calc = call.rel(0);
FlinkLogicalRank rank = call.rel(1);
FlinkLogicalRank newRank = new FlinkLogicalRank(rank.getCluster(), rank.getTraitSet(), rank.getInput(), rank.partitionKey(), rank.orderKey(), rank.rankType(), rank.rankRange(), rank.rankNumberType(), false);
RexProgram oldProgram = calc.getProgram();
Pair<List<RexNode>, RexNode> projectsAndCondition = getProjectsAndCondition(oldProgram);
RexProgram newProgram = RexProgram.create(newRank.getRowType(), projectsAndCondition.left, projectsAndCondition.right, oldProgram.getOutputRowType(), rank.getCluster().getRexBuilder());
FlinkLogicalCalc newCalc = FlinkLogicalCalc.create(newRank, newProgram);
call.transformTo(newCalc);
}
Aggregations