presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/AddIntermediateAggregations.java/AddIntermediateAggregations/outputsAsInputs
class AddIntermediateAggregations:    private static Map<Symbol, AggregationNode.Aggregation> outputsAsInputs(Map<Symbol, AggregationNode.Aggregation> assignments)
    {
        ImmutableMap.Builder<Symbol, AggregationNode.Aggregation> builder = ImmutableMap.builder();
        for (Map.Entry<Symbol, AggregationNode.Aggregation> entry : assignments.entrySet()) {
            Symbol output = entry.getKey();
            AggregationNode.Aggregation aggregation = entry.getValue();
            checkState(!aggregation.getOrderingScheme().isPresent(), "Intermediate aggregation does not support ORDER BY");
            builder.put(
                    output,
                    new AggregationNode.Aggregation(
                            aggregation.getResolvedFunction(),
                            ImmutableList.of(output.toSymbolReference()),
                            false,
                            Optional.empty(),
                            Optional.empty(),
                            Optional.empty()));  // No mask for INTERMEDIATE
        }
        return builder.build();
    }