LakshSingla commented on code in PR #16682:
URL: https://github.com/apache/druid/pull/16682#discussion_r1673384636


##########
extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/sql/HllSketchBaseSqlAggregator.java:
##########
@@ -211,4 +205,11 @@ protected abstract Aggregation toAggregation(
       boolean finalizeAggregations,
       AggregatorFactory aggregatorFactory
   );
+
+  private boolean validateInputComplexTypeName(ColumnType columnType)

Review Comment:
   Since the input to this method is a column type, and not a the complex type 
name, we should either have it `validateInputType` or 
`validateInputColumnType`. 
   nit:
   ```suggestion
     private boolean validateInputType(ColumnType columnType)
   ```



##########
sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/BuiltinApproxCountDistinctSqlAggregator.java:
##########
@@ -177,4 +177,10 @@ private static class 
BuiltinApproxCountDistinctSqlAggFunction extends SqlAggFunc
       );
     }
   }
+
+  private boolean validateInputComplexTypeName(ColumnType columnType)
+  {
+    return Objects.equals(columnType.getComplexTypeName(), 
HyperUniquesAggregatorFactory.TYPE.getComplexTypeName()) ||
+           Objects.equals(columnType.getComplexTypeName(), 
HyperUniquesAggregatorFactory.PRECOMPUTED_TYPE.getComplexTypeName());

Review Comment:
   This doesn't allow `UNKNOWN_COMPLEX` types. Should it support them as well? 
It looks inconsistent given that other aggregators allow `UNKNOWN_COMPLEX`



##########
processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java:
##########
@@ -137,17 +137,21 @@ public VectorAggregator factorizeVector(final 
VectorColumnSelectorFactory select
 
   /**
    * Validates whether the aggregator supports the input column type.
+   * Supported column types are complex types of hyperUnique, 
preComputedHyperUnique, as well as UNKNOWN_COMPLEX.

Review Comment:
   Also, the check on Line 131 in this file seems redundant after we have 
validated that the type is a supported type and complex. 



##########
extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/hll/sql/HllSketchSqlAggregatorTest.java:
##########
@@ -508,6 +524,33 @@ public void testApproxCountDistinctHllSketchIsRounded()
     );
   }
 
+  @Test
+  public void testApproxCountDistinctOnUnsupportedComplexColumn()
+  {
+    try {
+      testQuery("SELECT COUNT(distinct double_first_added) FROM 
druid.wikipedia_first_last", ImmutableList.of(), ImmutableList.of());
+      Assert.fail("query planning should fail");

Review Comment:
   In that case, `Assert.assertThrows` for 
`testApproxCountDistinctFunctionOnUnsupportedComplexColumn`



##########
processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java:
##########
@@ -137,17 +137,21 @@ public VectorAggregator factorizeVector(final 
VectorColumnSelectorFactory select
 
   /**
    * Validates whether the aggregator supports the input column type.
+   * Supported column types are complex types of hyperUnique, 
preComputedHyperUnique, as well as UNKNOWN_COMPLEX.

Review Comment:
   I wanted to check if this change is fine with primitive types - earlier in 
case of primitive selectors, we'd have returned 
`NoopVectorAggregator.instance`. Now it will throw an error. 



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