Class SubQueryDecorrelator

  • All Implemented Interfaces:
    org.apache.calcite.rel.RelShuttle

    public class SubQueryDecorrelator
    extends org.apache.calcite.rel.RelShuttleImpl
    SubQueryDecorrelator finds all correlated expressions in a SubQuery, and gets an equivalent non-correlated relational expression tree and correlation conditions.

    The Basic idea of SubQueryDecorrelator is from RelDecorrelator, however there are differences between them: 1. This class works with RexSubQuery, while RelDecorrelator works with LogicalCorrelate. 2. This class will get an equivalent non-correlated expressions tree and correlation conditions, while RelDecorrelator will replace all correlated expressions with non-correlated expressions that are produced from joining the RelNode. 3. This class supports both equi and non-equi correlation conditions, while RelDecorrelator only supports equi correlation conditions.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SubQueryDecorrelator.Result
      Result describing the relational expression after decorrelation and where to find the equivalent non-correlated expressions and correlated conditions.
      static class  SubQueryDecorrelator.SubQueryRelDecorrelator
      Pull out all correlation conditions from a given subquery to top level, and rebuild the subquery rel tree without correlation conditions.
    • Field Summary

      • Fields inherited from class org.apache.calcite.rel.RelShuttleImpl

        stack
    • Method Detail

      • decorrelateQuery

        public static SubQueryDecorrelator.Result decorrelateQuery​(org.apache.calcite.rel.RelNode rootRel)
        Decorrelates a subquery.

        This is the main entry point to SubQueryDecorrelator.

        Parameters:
        rootRel - The node which has SubQuery.
        Returns:
        Decorrelate result.
      • visitChild

        protected org.apache.calcite.rel.RelNode visitChild​(org.apache.calcite.rel.RelNode parent,
                                                            int i,
                                                            org.apache.calcite.rel.RelNode input)
        Overrides:
        visitChild in class org.apache.calcite.rel.RelShuttleImpl
      • visit

        public org.apache.calcite.rel.RelNode visit​(org.apache.calcite.rel.logical.LogicalFilter filter)
        Specified by:
        visit in interface org.apache.calcite.rel.RelShuttle
        Overrides:
        visit in class org.apache.calcite.rel.RelShuttleImpl