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



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/reduce/GroupByDataTableReducer.java
##########
@@ -171,106 +160,81 @@ public void reduceAndSetResults(String tableName, 
DataSchema dataSchema,
    */
   private void setSQLGroupByInResultTable(BrokerResponseNative 
brokerResponseNative, DataSchema dataSchema,
       Collection<DataTable> dataTables) {
-
+    DataSchema resultTableSchema = getSQLResultTableSchema(dataSchema);
     IndexedTable indexedTable = getIndexedTable(dataSchema, dataTables);
-
-    int[] finalSchemaMapIdx = null;
-    if (_sqlSelectionList != null) {
-      finalSchemaMapIdx = getFinalSchemaMapIdx();
-    }
-    List<Object[]> rows = new ArrayList<>();
     Iterator<Record> sortedIterator = indexedTable.iterator();
-    int numRows = 0;
-    while (numRows < _groupBy.getTopN() && sortedIterator.hasNext()) {
-      Record nextRecord = sortedIterator.next();
-      Object[] values = nextRecord.getValues();
-
-      int index = _numGroupBy;
-      int aggNum = 0;
-      while (index < _numColumns) {
-        values[index] = AggregationFunctionUtils
-            
.getSerializableValue(_aggregationFunctions[aggNum++].extractFinalResult(values[index]));
-        index++;
+    int limit = _queryContext.getLimit();
+    List<Object[]> rows = new ArrayList<>(limit);
+
+    if (_sqlQuery) {

Review comment:
       I am not sure why we had to change the logic. We already have support 
for schema mapping for a column right? getFinalSchemaMapIdx() is supposed to do 
that.




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