presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/PruneAggregationColumns.java/PruneAggregationColumns/pushDownProjectOff
class PruneAggregationColumns:    @Override
    protected Optional<PlanNode> pushDownProjectOff(
            PlanNodeIdAllocator idAllocator,
            AggregationNode aggregationNode,
            Set<Symbol> referencedOutputs)
    {
        Map<Symbol, AggregationNode.Aggregation> prunedAggregations = Maps.filterKeys(
                aggregationNode.getAggregations(),
                referencedOutputs::contains);

        if (prunedAggregations.size() == aggregationNode.getAggregations().size()) {
            return Optional.empty();
        }

        // PruneAggregationSourceColumns will subsequently project off any newly unused inputs.
        return Optional.of(
                new AggregationNode(
                        aggregationNode.getId(),
                        aggregationNode.getSource(),
                        prunedAggregations,
                        aggregationNode.getGroupingSets(),
                        aggregationNode.getPreGroupedSymbols(),
                        aggregationNode.getStep(),
                        aggregationNode.getHashSymbol(),
                        aggregationNode.getGroupIdSymbol()));
    }