gianm commented on code in PR #14249:
URL: https://github.com/apache/druid/pull/14249#discussion_r1240294783
##########
extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/sql/HllSketchApproxCountDistinctSqlAggregator.java:
##########
@@ -21,24 +21,29 @@
import org.apache.calcite.sql.SqlAggFunction;
import org.apache.calcite.sql.SqlFunctionCategory;
-import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.type.InferTypes;
-import org.apache.calcite.sql.type.OperandTypes;
-import org.apache.calcite.sql.type.ReturnTypes;
import org.apache.calcite.sql.type.SqlTypeFamily;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.druid.query.aggregation.AggregatorFactory;
import
org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator;
import org.apache.druid.sql.calcite.aggregation.Aggregation;
import org.apache.druid.sql.calcite.aggregation.SqlAggregator;
+import org.apache.druid.sql.calcite.expression.OperatorConversions;
import java.util.Collections;
public class HllSketchApproxCountDistinctSqlAggregator extends
HllSketchBaseSqlAggregator implements SqlAggregator
{
public static final String NAME = "APPROX_COUNT_DISTINCT_DS_HLL";
-
- private static final SqlAggFunction FUNCTION_INSTANCE = new
HllSketchApproxCountDistinctSqlAggFunction();
+ private static final SqlAggFunction FUNCTION_INSTANCE =
+ OperatorConversions.aggregatorBuilder(NAME)
+ .operandTypes(SqlTypeFamily.ANY,
SqlTypeFamily.NUMERIC, SqlTypeFamily.STRING)
Review Comment:
In the latest patch, I added `operandNames` which are used to generate the
signature for validation errors.
About the syntax, yeah, I was wanting to match it to `SqlFunction`. Feel
free to introduce a new syntax in a future patch 🙂. IMO it would make sense to
have a builder for `DefaultOperandTypeChecker` that builds up the operand list
one at a time. That would enable an alternate syntax like:
```
OperatorConversions
.aggregatorBuilder(NAME)
.operandTypeChecker(
OperandConversions
.checkerBuilder()
.operand("column", SqlTypeFamily.ANY)
.operand("lgK", SqlTypeFamily.NUMERIC).optional().literal()
.operand("tgtHllType", SqlTypeFamily.STRING).optional().literal()
.build()
)
.returnTypeNonNull(SqlTypeName.BIGINT)
.functionCategory(SqlFunctionCategory.NUMERIC)
.build();
```
--
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]