JackieTien97 commented on code in PR #19168:
URL: https://github.com/apache/iotdb/pull/19168#discussion_r4490702813


##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/grouped/AbstractGroupedApproxMostFrequentAccumulator.java:
##########
@@ -42,15 +43,22 @@ public void setGroupCount(long groupCount) {
 
   @Override
   public void evaluateIntermediate(int groupId, ColumnBuilder columnBuilder) {
-    columnBuilder.writeBinary(new 
Binary(state.getSpaceSavings().get(groupId).serialize()));
+    SpaceSaving<T> spaceSaving = state.getSpaceSavings().get(groupId);
+    if (spaceSaving == null || spaceSaving.isEmpty()) {
+      columnBuilder.appendNull();
+      return;

Review Comment:
   [P2] Handle empty BLOB groups in the overridden final evaluator
   
   Please also add the null/empty-state guard to 
`BlobGroupedApproxMostFrequentAccumulator.evaluateFinal()`. For a group whose 
BLOB values are all NULL, this inherited `evaluateIntermediate()` now emits 
NULL, and `BinaryGroupedApproxMostFrequentAccumulator.addIntermediate()` skips 
it, leaving the final group's state uninitialized. The BLOB-specific 
`evaluateFinal()` overrides the guarded base implementation and still calls 
`state.getSpaceSavings().get(groupId).getBuckets()` unconditionally, so a 
PARTIAL -> FINAL aggregation now throws an NPE. I reproduced this with the 
parent and PR accumulator sources: the parent returns `{}`, whereas this 
revision throws. Please add a grouped BLOB regression test covering an all-NULL 
group through partial/final aggregation, including alongside a nonempty group.



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

Reply via email to