Class DecorrelateLeftUnnestWithGlobalAggregation

  • All Implemented Interfaces:
    Rule<CorrelatedJoinNode>

    public class DecorrelateLeftUnnestWithGlobalAggregation
    extends Object
    implements Rule<CorrelatedJoinNode>
    This rule finds correlated UnnestNode in CorrelatedJoinNode's subquery and folds them into UnnestNode representing LEFT JOIN UNNEST. This rule transforms plans, where: - UnnestNode in subquery is based only on correlation symbols - UnnestNode in subquery is LEFT without filter - subquery contains global aggregation over the result of unnest Additionally, other global aggregations, grouped aggregations and projections in subquery are supported.

    Transforms:

     - CorrelatedJoin (LEFT or INNER) on true, correlation(c1, c2)
          - Input (a, c1, c2)
          - Aggregation
               global grouping
               agg <- agg1(x)
               - Projection
                    x <- foo(y)
                    - Aggregation
                         group by (g)
                         y <- agg2(u)
                         - Unnest LEFT
                              g <- unnest(c1)
                              u <- unnest(c2)
                              replicate: ()
     
    Into:
     - Projection (restrict outputs)
          - Aggregation
               group by (a, c1, c2, unique)
               agg <- agg1(x)
               - Projection
                    x <- foo(y)
                    - Aggregation
                         group by (g, a, c1, c2, unique)
                         y <- agg2(u)
                         - Unnest LEFT
                              g <- unnest(c1)
                              u <- unnest(c2)
                              replicate: (a, c1, c2, unique)
                              - AssignUniqueId unique
                                   - Input (a, c1, c2)