This is an automated email from the ASF dual-hosted git repository.

rongr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new a4c3286018 add null handling to sketch group-by (#12259)
a4c3286018 is described below

commit a4c3286018a7aaa89873f40a04f3b912fe0e1104
Author: Rong Rong <[email protected]>
AuthorDate: Thu Jan 11 14:00:34 2024 -0800

    add null handling to sketch group-by (#12259)
    
    * add null handling to sketch group-by
    * adding integration test for hitting the npe
    
    ---------
    
    Co-authored-by: Rong Rong <[email protected]>
---
 .../function/DistinctCountThetaSketchAggregationFunction.java |  8 ++++++++
 .../pinot/integration/tests/custom/ThetaSketchTest.java       | 11 +++++++++++
 2 files changed, 19 insertions(+)

diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
index 4a9a846acd..9cef1d1931 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
@@ -964,6 +964,14 @@ public class DistinctCountThetaSketchAggregationFunction
   @Override
   public List<ThetaSketchAccumulator> extractGroupByResult(GroupByResultHolder 
groupByResultHolder, int groupKey) {
     List result = groupByResultHolder.getResult(groupKey);
+    if (result == null) {
+      int numSketches = _filterEvaluators.size() + 1;
+      List<ThetaSketchAccumulator> thetaSketchAccumulators = new 
ArrayList<>(numSketches);
+      for (int i = 0; i < numSketches; i++) {
+        thetaSketchAccumulators.add(new 
ThetaSketchAccumulator(_setOperationBuilder, _accumulatorThreshold));
+      }
+      return thetaSketchAccumulators;
+    }
 
     if (result.get(0) instanceof Sketch) {
       int numSketches = result.size();
diff --git 
a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/custom/ThetaSketchTest.java
 
b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/custom/ThetaSketchTest.java
index 392ed8738c..e9b577d977 100644
--- 
a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/custom/ThetaSketchTest.java
+++ 
b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/custom/ThetaSketchTest.java
@@ -442,6 +442,17 @@ public class ThetaSketchTest extends 
CustomDataQueryClusterIntegrationTest {
       runAndAssert(query, expected);
     }
 
+    // group by sketch with filter
+    {
+      String query = "select dimValue, 
GET_THETA_SKETCH_ESTIMATE(THETA_SKETCH_INTERSECT( "
+          + "    DISTINCT_COUNT_RAW_THETA_SKETCH(thetaSketchCol, '') FILTER 
(WHERE dimName = 'gender'),"
+          + "    DISTINCT_COUNT_RAW_THETA_SKETCH(thetaSketchCol, '') FILTER 
(WHERE dimName != 'gender'))) "
+          + "  FROM " + getTableName() + " GROUP BY dimValue";
+      ImmutableMap<String, Integer> expected =
+          ImmutableMap.of("Female", 0, "Male", 0, "Math", 0, "History", 0, 
"Biology", 0);
+      runAndAssert(query, expected);
+    }
+
     // group by gender
     {
       String query = "select dimValue, 
distinctCountThetaSketch(thetaSketchCol) from " + getTableName()


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

Reply via email to