Class TransformCorrelatedGroupedAggregationWithProjection
java.lang.Object
io.trino.sql.planner.iterative.rule.TransformCorrelatedGroupedAggregationWithProjection
- All Implemented Interfaces:
Rule<CorrelatedJoinNode>
public class TransformCorrelatedGroupedAggregationWithProjection
extends Object
implements Rule<CorrelatedJoinNode>
This rule decorrelates a correlated subquery of INNER correlated join with:
- single grouped aggregation, or
- grouped aggregation over distinct operator (grouped aggregation with no aggregation assignments),
in case when the distinct operator cannot be de-correlated by PlanNodeDecorrelator
In the case of single aggregation, it transforms:
- CorrelatedJoin INNER (correlation: [c], filter: true, output: a, count, agg)
- Input (a, c)
- Project (x <- f(count), y <- f'(agg))
- Aggregation (group by b)
count <- count(*)
agg <- agg(d)
- Source (b, d) with correlated filter (b > c)
Into:
- Project (a <- a, x <- f(count), y <- f'(agg))
- Aggregation (group by [a, c, unique, b])
count <- count(*)
agg <- agg(d)
- INNER join (filter: b > c)
- UniqueId (unique)
- Input (a, c)
- Source (b, d) decorrelated
In the case of grouped aggregation over distinct operator, it transforms:
- CorrelatedJoin INNER (correlation: [c], filter: true, output: a, count, agg)
- Input (a, c)
- Project (x <- f(count), y <- f'(agg))
- Aggregation (group by b)
count <- count(*)
agg <- agg(b)
- Aggregation "distinct operator" group by [b]
- Source (b) with correlated filter (b > c)
Into:
- Project (a <- a, x <- f(count), y <- f'(agg))
- Aggregation (group by [a, c, unique, b])
count <- count(*)
agg <- agg(b)
- Aggregation "distinct operator" group by [a, c, unique, b]
- INNER join (filter: b > c)
- UniqueId (unique)
- Input (a, c)
- Source (b) decorrelated
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result -
Constructor Summary
ConstructorsConstructorDescriptionTransformCorrelatedGroupedAggregationWithProjection(PlannerContext plannerContext) -
Method Summary
Modifier and TypeMethodDescriptionapply(CorrelatedJoinNode correlatedJoinNode, Captures captures, Rule.Context context) Returns a pattern to which plan nodes this rule applies.
-
Constructor Details
-
TransformCorrelatedGroupedAggregationWithProjection
-
-
Method Details
-
getPattern
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<CorrelatedJoinNode>
-