Class AddIntermediateAggregations

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

public class AddIntermediateAggregations extends Object implements Rule<AggregationNode>
Adds INTERMEDIATE aggregations between an un-grouped FINAL aggregation and its preceding PARTIAL aggregation.

From:

 - Aggregation (FINAL)
   - RemoteExchange (GATHER)
     - Aggregation (PARTIAL)
 
To:
 - Aggregation (FINAL)
   - LocalExchange (GATHER)
     - Aggregation (INTERMEDIATE)
       - LocalExchange (ARBITRARY)
         - RemoteExchange (GATHER)
           - Aggregation (INTERMEDIATE)
             - LocalExchange (GATHER)
               - Aggregation (PARTIAL)