presto-main/src/main/java/io/prestosql/sql/analyzer/ExpressionTreeUtils.java/ExpressionTreeUtils/isAggregation
class ExpressionTreeUtils:    private static boolean isAggregation(FunctionCall functionCall, Metadata metadata)
    {
        return ((metadata.isAggregationFunction(functionCall.getName()) || functionCall.getFilter().isPresent())
                && !functionCall.getWindow().isPresent())
                || functionCall.getOrderBy().isPresent();
    }