Class PreAggregateCaseAggregations

java.lang.Object
io.trino.sql.planner.iterative.rule.PreAggregateCaseAggregations
All Implemented Interfaces:
Rule<AggregationNode>

public class PreAggregateCaseAggregations extends Object implements Rule<AggregationNode>
Rule that transforms selected aggregations from:
 
 - Aggregation[key]: sum(aggr1), sum(aggr2), ..., sum(aggrN)
   - Project:
       aggr1 = CASE WHEN col=1 THEN expr ELSE 0
       aggr2 = CASE WHEN col=2 THEN expr ELSE null
       ...
       aggrN = CASE WHEN col=N THEN expr
     - source
 
 
into:
 
 - Aggregation[key]: sum(aggr1), sum(aggr2), ..., sum(aggrN)
   - Project:
       aggr1 = CASE WHEN col=1 THEN pre_aggregate
       aggr2 = CASE WHEN col=2 THEN pre_aggregate
       ..
       aggrN = CASE WHEN col=N THEN pre_aggregate
     - Aggregation[key, col]: pre_aggregate = sum(expr)
       - source