Jackie-Jiang commented on a change in pull request #5605:
URL: https://github.com/apache/incubator-pinot/pull/5605#discussion_r445182136



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/reduce/GroupByDataTableReducer.java
##########
@@ -486,69 +447,44 @@ private void setGroupByResults(BrokerResponseNative 
brokerResponseNative, boolea
       finalResultMaps[i] = finalResultMap;
     }
 
-    int aggregationNumsInFinalResult = 0;
-    for (int i = 0; i < _numAggregationFunctions; i++) {
-      if (aggregationFunctionsSelectStatus[i]) {
-        aggregationNumsInFinalResult++;
-      }
-    }
-
-    if (aggregationNumsInFinalResult > 0) {
-      String[] finalColumnNames = new String[aggregationNumsInFinalResult];
-      Map<String, Comparable>[] finalOutResultMaps = new 
Map[aggregationNumsInFinalResult];
-      String[] finalResultTableAggNames = new 
String[aggregationNumsInFinalResult];
-      AggregationFunction[] finalAggregationFunctions = new 
AggregationFunction[aggregationNumsInFinalResult];
-      int count = 0;
-      for (int i = 0; i < _numAggregationFunctions; i++) {
-        if (aggregationFunctionsSelectStatus[i]) {
-          finalColumnNames[count] = columnNames[i];
-          finalOutResultMaps[count] = finalResultMaps[i];
-          AggregationFunction aggregationFunction = _aggregationFunctions[i];
-          finalResultTableAggNames[count] = 
aggregationFunction.getResultColumnName();
-          finalAggregationFunctions[count] = aggregationFunction;
-          count++;
+    // Trim the final result maps and set them into the broker response.
+    AggregationGroupByTrimmingService aggregationGroupByTrimmingService =
+        new AggregationGroupByTrimmingService(_aggregationFunctions, 
_queryContext.getLimit());
+    List<GroupByResult>[] groupByResultLists = 
aggregationGroupByTrimmingService.trimFinalResults(finalResultMaps);
+
+    if (_responseFormatSql) {

Review comment:
       Agree, but we have to keep this behavior for backward-compatibility.
   Once we deprecate PQL semantic, all these checks will gone




----------------------------------------------------------------
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.

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

Reply via email to