presto-main/src/main/java/io/prestosql/sql/planner/plan/AggregationNode.java/AggregationNode/isDecomposable
class AggregationNode:    public boolean isDecomposable(Metadata metadata)
    {
        boolean hasOrderBy = getAggregations().values().stream()
                .map(Aggregation::getOrderingScheme)
                .anyMatch(Optional::isPresent);

        boolean hasDistinct = getAggregations().values().stream()
                .anyMatch(Aggregation::isDistinct);

        boolean decomposableFunctions = getAggregations().values().stream()
                .map(Aggregation::getResolvedFunction)
                .map(metadata::getAggregationFunctionMetadata)
                .map(AggregationFunctionMetadata::getIntermediateType)
                .allMatch(Optional::isPresent);

        return !hasOrderBy && !hasDistinct && decomposableFunctions;
    }