public class PushAggregationThroughOuterJoin extends Object implements Rule<AggregationNode>
When the aggregation is pushed down, we still need to perform aggregations on the null values that come out of the absent values in an outer join. We add a cross join with a row of aggregations on null literals, and coalesce the aggregation that results from the left outer join with the result of the aggregation over nulls.
Example:
- Filter ("nationkey" > "avg")
- Aggregate(Group by: all columns from the left table, aggregation:
avg("n2.nationkey"))
- LeftJoin("regionkey" = "regionkey")
- AssignUniqueId (nation)
- Tablescan (nation)
- Tablescan (nation)
Is rewritten to:
- Filter ("nationkey" > "avg")
- project(regionkey, coalesce("avg", "avg_over_null")
- CrossJoin
- LeftJoin("regionkey" = "regionkey")
- AssignUniqueId (nation)
- Tablescan (nation)
- Aggregate(Group by: regionkey, aggregation:
avg(nationkey))
- Tablescan (nation)
- Aggregate
avg(null_literal)
- Values (null_literal)
Rule.Context, Rule.Result| Constructor and Description |
|---|
PushAggregationThroughOuterJoin() |
| Modifier and Type | Method and Description |
|---|---|
Rule.Result |
apply(AggregationNode aggregation,
Captures captures,
Rule.Context context) |
Pattern<AggregationNode> |
getPattern()
Returns a pattern to which plan nodes this rule applies.
|
boolean |
isEnabled(Session session) |
public Pattern<AggregationNode> getPattern()
RulegetPattern in interface Rule<AggregationNode>public boolean isEnabled(Session session)
isEnabled in interface Rule<AggregationNode>public Rule.Result apply(AggregationNode aggregation, Captures captures, Rule.Context context)
apply in interface Rule<AggregationNode>Copyright © 2012–2019. All rights reserved.