vvivekiyer commented on code in PR #10248: URL: https://github.com/apache/pinot/pull/10248#discussion_r1116421093
########## pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotAggregateExchangeNodeInsertRule.java: ########## @@ -119,23 +132,25 @@ public void onMatch(RelOptRuleCall call) { } // 3. attach intermediate agg stage. - RelNode newAggNode = makeNewIntermediateAgg(call, oldAggRel, exchange); + RelNode newAggNode = makeNewIntermediateAgg(call, oldAggRel, exchange, true, null, null); call.transformTo(newAggNode); } - private RelNode makeNewIntermediateAgg(RelOptRuleCall ruleCall, Aggregate oldAggRel, LogicalExchange exchange) { + /** + * Creates an intermediate stage aggregation. If argList and groupByList are passed by the caller, they are used to + * create the new aggregation function. If not, they are fetched from the existing aggregation function with the + * assumption that the intermediate aggregation is done after a leaf aggregation and exchange. + */ + private RelNode makeNewIntermediateAgg(RelOptRuleCall ruleCall, Aggregate oldAggRel, LogicalExchange exchange, + boolean isLeafStageAggregationPresent, List<Integer> argList, List<Integer> groupByList) { // add the exchange as the input node to the relation builder. RelBuilder relBuilder = ruleCall.builder(); relBuilder.push(exchange); - List<RexNode> inputExprs = new ArrayList<>(relBuilder.fields()); // make input ref to the exchange after the leaf aggregate. RexBuilder rexBuilder = exchange.getCluster().getRexBuilder(); final int nGroups = oldAggRel.getGroupCount(); - for (int i = 0; i < nGroups; i++) { Review Comment: This seemed unnecessary based on my code reading. But I am not sure, so adding it back. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org