Package org.apache.calcite.sql2rel
Class RelDecorrelator
- java.lang.Object
-
- org.apache.calcite.sql2rel.RelDecorrelator
-
- All Implemented Interfaces:
org.apache.calcite.util.ReflectiveVisitor
public class RelDecorrelator extends Object implements org.apache.calcite.util.ReflectiveVisitor
Copied to fix calcite issues. FLINK modifications are at lines- Was changed within FLINK-29280, FLINK-28682, FLINK-35804: Line 218 ~ 225, Line 273 ~ 288
- Should be removed after fix of FLINK-29540: Line 293 ~ 299
- Should be removed after fix of FLINK-29540: Line 311 ~ 317
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RelDecorrelator.AdjustProjectForCountAggregateRule
Planner rule that adjusts projects when counts are added.static interface
RelDecorrelator.Config
Base configuration for rules that are non-static in a RelDecorrelator.protected static class
RelDecorrelator.CorelMap
A map of the locations ofCorrelate
in a tree ofRelNode
s.static class
RelDecorrelator.CorelMapBuilder
Builds aRelDecorrelator.CorelMap
.static class
RelDecorrelator.RemoveCorrelationForScalarAggregateRule
Planner rule that removes correlations for scalar aggregates.static class
RelDecorrelator.RemoveCorrelationForScalarProjectRule
Planner rule that removes correlations for scalar projects.static class
RelDecorrelator.RemoveSingleAggregateRule
Rule to remove an Aggregate with SINGLE_VALUE.
-
Field Summary
Fields Modifier and Type Field Description protected RelDecorrelator.CorelMap
cm
protected org.apache.calcite.plan.Context
context
protected @Nullable org.apache.calcite.rel.RelNode
currentRel
protected org.apache.calcite.util.ReflectUtil.MethodDispatcher<@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame>
dispatcher
protected HashSet<org.apache.calcite.rel.core.Correlate>
generatedCorRels
protected Map<org.apache.calcite.rel.RelNode,org.apache.calcite.sql2rel.RelDecorrelator.Frame>
map
Built during decorrelation, of rel to all the newly created correlated variables in its output, and to map old input positions to new input positions.protected RelBuilder
relBuilder
-
Constructor Summary
Constructors Modifier Constructor Description protected
RelDecorrelator(RelDecorrelator.CorelMap cm, org.apache.calcite.plan.Context context, RelBuilder relBuilder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected org.apache.calcite.rel.RelNode
decorrelate(org.apache.calcite.rel.RelNode root)
protected org.apache.calcite.rex.RexNode
decorrelateExpr(org.apache.calcite.rel.RelNode currentRel, Map<org.apache.calcite.rel.RelNode,org.apache.calcite.sql2rel.RelDecorrelator.Frame> map, RelDecorrelator.CorelMap cm, org.apache.calcite.rex.RexNode exp)
static org.apache.calcite.rel.RelNode
decorrelateQuery(org.apache.calcite.rel.RelNode rootRel)
Deprecated.static org.apache.calcite.rel.RelNode
decorrelateQuery(org.apache.calcite.rel.RelNode rootRel, RelBuilder relBuilder)
Decorrelates a query.@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.core.Aggregate rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.core.Correlate rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.core.Filter rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.core.Join rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.core.Project rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.core.Sort rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.core.Values rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.logical.LogicalAggregate rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.logical.LogicalCorrelate rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.logical.LogicalFilter rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.logical.LogicalJoin rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.logical.LogicalProject rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(LogicalSnapshot rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.logical.LogicalTableFunctionScan rel, boolean isCorVarDefined)
@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
decorrelateRel(org.apache.calcite.rel.RelNode rel, boolean isCorVarDefined)
Fallback if none of the otherdecorrelateRel
methods match.@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame
getInvoke(org.apache.calcite.rel.RelNode r, boolean isCorVarDefined, @Nullable org.apache.calcite.rel.RelNode parent)
protected Collection<org.apache.calcite.plan.RelOptRule>
getPostDecorrelateRules()
Returns the rules applied on the rel after decorrelation, never null.protected RelDecorrelator
getVisitor()
Returns thevisitor
on which theMethodDispatcher
dispatches eachdecorrelateRel
method, the default implementation returns this instance, if you got a sub-class, override this method to replace thevisitor
as the sub-class instance.protected org.apache.calcite.tools.RelBuilderFactory
relBuilderFactory()
protected org.apache.calcite.rex.RexNode
removeCorrelationExpr(org.apache.calcite.rex.RexNode exp, boolean projectPulledAboveLeftCorrelator)
protected org.apache.calcite.rex.RexNode
removeCorrelationExpr(org.apache.calcite.rex.RexNode exp, boolean projectPulledAboveLeftCorrelator, Set<Integer> isCount)
protected org.apache.calcite.rex.RexNode
removeCorrelationExpr(org.apache.calcite.rex.RexNode exp, boolean projectPulledAboveLeftCorrelator, org.apache.calcite.rex.RexInputRef nullIndicator)
org.apache.calcite.rel.RelNode
removeCorrelationViaRule(org.apache.calcite.rel.RelNode root)
-
-
-
Field Detail
-
relBuilder
protected final RelBuilder relBuilder
-
cm
protected RelDecorrelator.CorelMap cm
-
dispatcher
protected final org.apache.calcite.util.ReflectUtil.MethodDispatcher<@Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame> dispatcher
-
currentRel
protected @Nullable org.apache.calcite.rel.RelNode currentRel
-
context
protected final org.apache.calcite.plan.Context context
-
map
protected final Map<org.apache.calcite.rel.RelNode,org.apache.calcite.sql2rel.RelDecorrelator.Frame> map
Built during decorrelation, of rel to all the newly created correlated variables in its output, and to map old input positions to new input positions. This is from the view point of the parent rel of a new rel.
-
generatedCorRels
protected final HashSet<org.apache.calcite.rel.core.Correlate> generatedCorRels
-
-
Constructor Detail
-
RelDecorrelator
protected RelDecorrelator(RelDecorrelator.CorelMap cm, org.apache.calcite.plan.Context context, RelBuilder relBuilder)
-
-
Method Detail
-
decorrelateQuery
@Deprecated public static org.apache.calcite.rel.RelNode decorrelateQuery(org.apache.calcite.rel.RelNode rootRel)
Deprecated.
-
decorrelateQuery
public static org.apache.calcite.rel.RelNode decorrelateQuery(org.apache.calcite.rel.RelNode rootRel, RelBuilder relBuilder)
Decorrelates a query.This is the main entry point to
RelDecorrelator
.- Parameters:
rootRel
- Root node of the queryrelBuilder
- Builder for relational expressions- Returns:
- Equivalent query with all
Correlate
instances removed
-
relBuilderFactory
protected org.apache.calcite.tools.RelBuilderFactory relBuilderFactory()
-
decorrelate
protected org.apache.calcite.rel.RelNode decorrelate(org.apache.calcite.rel.RelNode root)
-
removeCorrelationViaRule
public org.apache.calcite.rel.RelNode removeCorrelationViaRule(org.apache.calcite.rel.RelNode root)
-
decorrelateExpr
protected org.apache.calcite.rex.RexNode decorrelateExpr(org.apache.calcite.rel.RelNode currentRel, Map<org.apache.calcite.rel.RelNode,org.apache.calcite.sql2rel.RelDecorrelator.Frame> map, RelDecorrelator.CorelMap cm, org.apache.calcite.rex.RexNode exp)
-
removeCorrelationExpr
protected org.apache.calcite.rex.RexNode removeCorrelationExpr(org.apache.calcite.rex.RexNode exp, boolean projectPulledAboveLeftCorrelator)
-
removeCorrelationExpr
protected org.apache.calcite.rex.RexNode removeCorrelationExpr(org.apache.calcite.rex.RexNode exp, boolean projectPulledAboveLeftCorrelator, org.apache.calcite.rex.RexInputRef nullIndicator)
-
removeCorrelationExpr
protected org.apache.calcite.rex.RexNode removeCorrelationExpr(org.apache.calcite.rex.RexNode exp, boolean projectPulledAboveLeftCorrelator, Set<Integer> isCount)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.RelNode rel, boolean isCorVarDefined)
Fallback if none of the otherdecorrelateRel
methods match.
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.core.Sort rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.core.Values rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.logical.LogicalAggregate rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.core.Aggregate rel, boolean isCorVarDefined)
-
getInvoke
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame getInvoke(org.apache.calcite.rel.RelNode r, boolean isCorVarDefined, @Nullable org.apache.calcite.rel.RelNode parent)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.logical.LogicalProject rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.core.Project rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(LogicalSnapshot rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.logical.LogicalTableFunctionScan rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.logical.LogicalFilter rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.core.Filter rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.logical.LogicalCorrelate rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.core.Correlate rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.logical.LogicalJoin rel, boolean isCorVarDefined)
-
decorrelateRel
public @Nullable org.apache.calcite.sql2rel.RelDecorrelator.Frame decorrelateRel(org.apache.calcite.rel.core.Join rel, boolean isCorVarDefined)
-
getVisitor
protected RelDecorrelator getVisitor()
Returns thevisitor
on which theMethodDispatcher
dispatches eachdecorrelateRel
method, the default implementation returns this instance, if you got a sub-class, override this method to replace thevisitor
as the sub-class instance.
-
getPostDecorrelateRules
protected Collection<org.apache.calcite.plan.RelOptRule> getPostDecorrelateRules()
Returns the rules applied on the rel after decorrelation, never null.
-
-