Search in sources :

Example 1 with FlinkLogicalRank

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);
}
Also used : FlinkLogicalCalc(org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalCalc) ImmutableBitSet(org.apache.calcite.util.ImmutableBitSet) FlinkLogicalRank(org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalRank)

Example 2 with FlinkLogicalRank

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);
}
Also used : FlinkLogicalCalc(org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalCalc) FlinkLogicalRank(org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalRank) RexProgram(org.apache.calcite.rex.RexProgram) List(java.util.List) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

FlinkLogicalCalc (org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalCalc)2 FlinkLogicalRank (org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalRank)2 List (java.util.List)1 RexNode (org.apache.calcite.rex.RexNode)1 RexProgram (org.apache.calcite.rex.RexProgram)1 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)1