presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/PruneAggregationSourceColumns.java/PruneAggregationSourceColumns/apply
class PruneAggregationSourceColumns:    @Override
    public Result apply(AggregationNode aggregationNode, Captures captures, Context context)
    {
        Set<Symbol> requiredInputs = Streams.concat(
                aggregationNode.getGroupingKeys().stream(),
                aggregationNode.getHashSymbol().map(Stream::of).orElse(Stream.empty()),
                aggregationNode.getAggregations().values().stream()
                        .flatMap(PruneAggregationSourceColumns::getAggregationInputs))
                .collect(toImmutableSet());

        return restrictChildOutputs(context.getIdAllocator(), aggregationNode, requiredInputs)
                .map(Result::ofPlanNode)
                .orElse(Result.empty());
    }