Jackie-Jiang commented on code in PR #19201:
URL: https://github.com/apache/pinot/pull/19201#discussion_r3751886328


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/blocks/results/AggregationResultsBlock.java:
##########
@@ -124,73 +123,32 @@ public DataTable getDataTable()
       return dataTableBuilder.build();
     }
 
-    boolean returnFinalResult = _queryContext.isServerReturnFinalResult();
-    if (_queryContext.isNullHandlingEnabled()) {
-      RoaringBitmap[] nullBitmaps = new RoaringBitmap[numColumns];
+    // NOTE: Nulls are serialized through the builder's null-aware path 
regardless of the query's null-handling
+    // option. Aggregation functions whose accumulator has no identity element 
(MINSTRING, MAXSTRING, ANYVALUE)
+    // return a null intermediate result in both modes, and their result 
column type is not OBJECT.
+    dataTableBuilder.startRow();
+    if (_queryContext.isServerReturnFinalResult()) {
       for (int i = 0; i < numColumns; i++) {
-        nullBitmaps[i] = new RoaringBitmap();
-      }
-      dataTableBuilder.startRow();
-      if (returnFinalResult) {
-        for (int i = 0; i < numColumns; i++) {
-          Object result = 
_aggregationFunctions[i].extractFinalResult(_results.get(i));
-          if (result == null) {
-            result = columnDataTypes[i].getNullPlaceholder();
-            nullBitmaps[i].add(0);
-          }
-          assert result != null;
+        Object result = 
_aggregationFunctions[i].extractFinalResult(_results.get(i));
+        if (result == null) {
+          dataTableBuilder.setNull(i);

Review Comment:
   Good catch — there were no `serverReturnFinalResult` usages in any test in 
the repo, so this branch had no coverage at all.
   
   Added 
`aggregationNoMatchingRowsReturningFinalResultWithNullHandlingDisabled` / 
`...Enabled` in `MaxStringAggregationFunctionTest`, via a 
`getDeclaringTable(boolean, Map)` overload that threads the option through the 
existing `FluentQueryTest.withExtraQueryOptions`.
   
   Worth noting for anyone reading this later: it is not an opt-in path. 
`BaseSingleStageBrokerRequestHandler` sets `serverReturnFinalResult=true` on 
its own whenever `numServers == 1`, so any single-server table finalizes on the 
server by default and a null `extractFinalResult` lands in a column typed by 
`getFinalResultColumnType()` — `STRING` here, a 4-byte slot, same as the 
intermediate type. I've corrected the PR description, which described this as a 
secondary path.



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