xiangfu0 commented on code in PR #18873:
URL: https://github.com/apache/pinot/pull/18873#discussion_r3782501447


##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountCPCSketchAggregationFunction.java:
##########
@@ -194,20 +196,30 @@ public void aggregate(int length, AggregationResultHolder 
aggregationResultHolde
           cpcSketch.update(stringValues[i]);
         }
         break;
+      // Reached only by UUID: a real BYTES column is a serialized CPC sketch 
and is handled above.
+      case BYTES:
+        byte[][] uuidValues = blockValSet.getBytesValuesSV();
+        for (int i = 0; i < length; i++) {
+          cpcSketch.update(uuidValues[i]);
+        }
+        break;
       default:
         throw new IllegalStateException("Illegal data type for 
DISTINCT_COUNT_CPC aggregation function: " + storedType);
     }
-    CpcSketchAccumulator cpcSketchAccumulator = 
getAccumulator(aggregationResultHolder);
-    cpcSketchAccumulator.apply(cpcSketch);
+    // The updated CpcSketch already lives in the holder (getCpcSketch stored 
it); extractAggregationResult
+    // converts it to a CpcSketchAccumulator. Reading the holder as an 
accumulator here would
+    // ClassCastException — the holder slot contains the sketch, not an 
accumulator.
   }
 
   @Override
   public void aggregateGroupBySV(int length, int[] groupKeyArray, 
GroupByResultHolder groupByResultHolder,
       Map<ExpressionContext, BlockValSet> blockValSetMap) {
     BlockValSet blockValSet = blockValSetMap.get(_expression);
 
+    DataType dataType = blockValSet.getValueType();
+    DataType storedType = dataType.getStoredType();
+
     // Treat BYTES value as serialized CPC Sketch
-    DataType storedType = blockValSet.getValueType().getStoredType();
     if (storedType == FieldSpec.DataType.BYTES) {

Review Comment:
    if (storedType == DataType.BYTES && dataType != DataType.UUID) {



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