@Override
        public LogicalPlan apply(LogicalPlan oldPlan) {
            return oldPlan.resolveOperators(plan -> {
                if (plan instanceof Project) {
                    Project project = (Project) plan;
                    if (containsAggregates(up(project.projectList))) {
                        return new Aggregate(empty(), project.projectList, project.child());
                    }
                }
                return plan;
            });
        }
Turns projections that contain aggregate expressions into aggregations.
indexr-query-opt/src/main/java/io/indexr/query/Analyzer.java