public class TransformCorrelatedScalarAggregationToJoin extends Object implements Rule<LateralJoinNode>
This optimizer rewrites correlated scalar aggregation subquery to left outer join in a way described here: https://github.com/prestosql/presto/wiki/Correlated-subqueries
From:
- LateralJoin (with correlation list: [C])
- (input) plan which produces symbols: [A, B, C]
- (subquery) Aggregation(GROUP BY (); functions: [sum(F), count(), ...]
- Filter(D = C AND E > 5)
- plan which produces symbols: [D, E, F]
to:
- Aggregation(GROUP BY A, B, C, U; functions: [sum(F), count(non_null), ...]
- Join(LEFT_OUTER, D = C)
- AssignUniqueId(adds symbol U)
- (input) plan which produces symbols: [A, B, C]
- Filter(E > 5)
- projection which adds non null symbol used for count() function
- plan which produces symbols: [D, E, F]
Note that only conjunction predicates in FilterNode are supported
Rule.Context, Rule.Result| Constructor and Description |
|---|
TransformCorrelatedScalarAggregationToJoin(FunctionRegistry functionRegistry) |
| Modifier and Type | Method and Description |
|---|---|
Rule.Result |
apply(LateralJoinNode lateralJoinNode,
Captures captures,
Rule.Context context) |
Pattern<LateralJoinNode> |
getPattern()
Returns a pattern to which plan nodes this rule applies.
|
public TransformCorrelatedScalarAggregationToJoin(FunctionRegistry functionRegistry)
public Pattern<LateralJoinNode> getPattern()
RulegetPattern in interface Rule<LateralJoinNode>public Rule.Result apply(LateralJoinNode lateralJoinNode, Captures captures, Rule.Context context)
apply in interface Rule<LateralJoinNode>Copyright © 2012–2019. All rights reserved.