Class MultipleDistinctAggregationsToSubqueries
java.lang.Object
io.trino.sql.planner.iterative.rule.MultipleDistinctAggregationsToSubqueries
- All Implemented Interfaces:
Rule<AggregationNode>
public class MultipleDistinctAggregationsToSubqueries
extends Object
implements Rule<AggregationNode>
Transforms plans of the following shape:
- Aggregation
GROUP BY (k)
F1(DISTINCT a0, a1, ...)
F2(DISTINCT b0, b1, ...)
F3(DISTINCT c0, c1, ...)
- X
into
- Join
on left.k = right.k
- Aggregation
GROUP BY (k)
F1(DISTINCT a0, a1, ...)
F2(DISTINCT b0, b1, ...)
- X
- Aggregation
GROUP BY (k)
F3(DISTINCT c0, c1, ...)
- X
This improves plan parallelism and allows SingleDistinctAggregationToGroupBy to optimize the single input distinct aggregation further.
The cost is we calculate X and GROUP BY (k) multiple times, so this rule is only beneficial if the calculations are cheap compared to
other distinct aggregation strategies.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result -
Constructor Summary
ConstructorsConstructorDescriptionMultipleDistinctAggregationsToSubqueries(TaskCountEstimator taskCountEstimator, Metadata metadata) -
Method Summary
Modifier and TypeMethodDescriptionapply(AggregationNode aggregationNode, Captures captures, Rule.Context context) Returns a pattern to which plan nodes this rule applies.static booleanisAggregationCandidateForSplittingToSubqueries(AggregationNode aggregationNode)
-
Constructor Details
-
MultipleDistinctAggregationsToSubqueries
public MultipleDistinctAggregationsToSubqueries(TaskCountEstimator taskCountEstimator, Metadata metadata)
-
-
Method Details
-
isAggregationCandidateForSplittingToSubqueries
public static boolean isAggregationCandidateForSplittingToSubqueries(AggregationNode aggregationNode) -
getPattern
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<AggregationNode>
-
apply
- Specified by:
applyin interfaceRule<AggregationNode>
-