Class 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
    1. Was changed within FLINK-29280, FLINK-28682, FLINK-35804: Line 218 ~ 225, Line 273 ~ 288
    2. Should be removed after fix of FLINK-29540: Line 293 ~ 299
    3. Should be removed after fix of FLINK-29540: Line 311 ~ 317
    • 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  
    • 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 other decorrelateRel 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 the visitor on which the MethodDispatcher dispatches each decorrelateRel method, the default implementation returns this instance, if you got a sub-class, override this method to replace the visitor 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
      • 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
    • 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 query
        relBuilder - 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 other decorrelateRel 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 the visitor on which the MethodDispatcher dispatches each decorrelateRel method, the default implementation returns this instance, if you got a sub-class, override this method to replace the visitor 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.