Class CorrelateSortToRankRule
java.lang.Object
org.apache.calcite.plan.RelOptRule
org.apache.calcite.plan.RelRule<CorrelateSortToRankRule.CorrelateSortToRankRuleConfig>
org.apache.flink.table.planner.plan.rules.logical.CorrelateSortToRankRule
@Enclosing
public class CorrelateSortToRankRule
extends org.apache.calcite.plan.RelRule<CorrelateSortToRankRule.CorrelateSortToRankRuleConfig>
Planner rule that rewrites sort correlation to a Rank. Typically, the following plan
LogicalProject(state=[$0], name=[$1])
+- LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
:- LogicalAggregate(group=[{0}])
: +- LogicalProject(state=[$1])
: +- LogicalTableScan(table=[[default_catalog, default_database, cities]])
+- LogicalSort(sort0=[$1], dir0=[DESC-nulls-last], fetch=[3])
+- LogicalProject(name=[$0], pop=[$2])
+- LogicalFilter(condition=[=($1, $cor0.state)])
+- LogicalTableScan(table=[[default_catalog, default_database, cities]])
would be transformed to
LogicalProject(state=[$0], name=[$1])
+- LogicalProject(state=[$1], name=[$0], pop=[$2])
+- LogicalRank(rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=3],
partitionBy=[$1], orderBy=[$2 DESC], select=[name=$0, state=$1, pop=$2])
+- LogicalTableScan(table=[[default_catalog, default_database, cities]])
To match the Correlate, the LHS needs to be a global Aggregate on a scan, the RHS should be a Sort with an equal Filter predicate whose keys are same with the LHS grouping keys.
This rule can only be used in HepPlanner.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRule configuration.Nested classes/interfaces inherited from class org.apache.calcite.plan.RelRule
org.apache.calcite.plan.RelRule.Config, org.apache.calcite.plan.RelRule.Done, org.apache.calcite.plan.RelRule.MatchHandler<R extends org.apache.calcite.plan.RelOptRule>, org.apache.calcite.plan.RelRule.OperandBuilder, org.apache.calcite.plan.RelRule.OperandDetailBuilder<R extends org.apache.calcite.rel.RelNode>, org.apache.calcite.plan.RelRule.OperandTransformNested classes/interfaces inherited from class org.apache.calcite.plan.RelOptRule
org.apache.calcite.plan.RelOptRule.ConverterRelOptRuleOperand -
Field Summary
FieldsFields inherited from class org.apache.calcite.plan.RelRule
configFields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Methods inherited from class org.apache.calcite.plan.RelOptRule
any, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
CorrelateSortToRankRule
-
-
Method Details
-
matches
public boolean matches(org.apache.calcite.plan.RelOptRuleCall call) - Overrides:
matchesin classorg.apache.calcite.plan.RelOptRule
-
onMatch
public void onMatch(org.apache.calcite.plan.RelOptRuleCall call) - Specified by:
onMatchin classorg.apache.calcite.plan.RelOptRule
-