walterddr commented on code in PR #9582:
URL: https://github.com/apache/pinot/pull/9582#discussion_r996319049


##########
pinot-core/src/main/java/org/apache/pinot/core/query/reduce/DistinctDataTableReducer.java:
##########
@@ -65,13 +66,32 @@ public void reduceAndSetResults(String tableName, 
DataSchema dataSchema,
     // inside a DataTable
 
     // Gather all non-empty DistinctTables
+    // TODO: until we upgrade to newer version of pinot, we have to keep both 
code path. remove after 0.12.0 release.
+    // This is to work with server rolling upgrade when partially returned as 
DistinctTable Obj and partially regular
+    // DataTable; if all returns are DataTable we can directly merge with 
priority queue (with dedup).
     List<DistinctTable> nonEmptyDistinctTables = new 
ArrayList<>(dataTableMap.size());
     for (DataTable dataTable : dataTableMap.values()) {
-      DataTable.CustomObject customObject = dataTable.getCustomObject(0, 0);
-      assert customObject != null;
-      DistinctTable distinctTable = ObjectSerDeUtils.deserialize(customObject);
-      if (!distinctTable.isEmpty()) {
-        nonEmptyDistinctTables.add(distinctTable);
+      if (dataTable.getDataSchema().getColumnNames().length == 1
+          && dataTable.getDataSchema().getColumnDataType(0) == 
ColumnDataType.OBJECT) {
+        // distinctTable is still being returned as a single object
+        DataTable.CustomObject customObject = dataTable.getCustomObject(0, 0);
+        assert customObject != null;
+        DistinctTable distinctTable = 
ObjectSerDeUtils.deserialize(customObject);
+        if (!distinctTable.isEmpty()) {
+          nonEmptyDistinctTables.add(distinctTable);
+        }
+      } else {
+        // distinctTable is still being returned as normal data table.
+        if (dataTable.getNumberOfRows() > 0) {
+          List<Record> records = new ArrayList<>(dataTable.getNumberOfRows());
+          List<Object[]> rows =
+              
SelectionOperatorUtils.reduceWithoutOrdering(Collections.singleton(dataTable), 
_queryContext.getLimit(),

Review Comment:
   👍 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to