FrankChen021 commented on code in PR #20782:
URL: https://github.com/apache/druid/pull/20782#discussion_r4442520935


##########
extensions-contrib/tdigestsketch/src/main/java/org/apache/druid/query/aggregation/tdigestsketch/sql/TDigestGenerateSketchSqlAggregator.java:
##########
@@ -154,7 +154,9 @@ private static class TDigestGenerateSketchSqlAggFunction 
extends SqlAggFunction
           DefaultOperandTypeChecker
               .builder()
               .operandNames("column", "compression")
-              .operandTypes(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC)
+              .operandTypes(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC)
+              .operandComplexTypes(0, TDigestSketchAggregatorFactory.TYPE)
+              .coercibleOperands(0)

Review Comment:
   Rechecked the current head and all 22 changed files: both builders now use 
the OperandType declarations, the old helper APIs are removed consistently, and 
the empty-varargs caller is handled. No remaining issue from this thread.
   
   <!-- mergelens:review -->



##########
sql/src/main/java/org/apache/druid/sql/calcite/expression/OperandType.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.sql.calcite.expression;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.type.SqlTypeFamily;
+import org.apache.druid.error.DruidException;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.sql.calcite.table.RowSignatures;
+
+/**
+ * Type of one operand of a {@link DefaultOperandTypeChecker}: a {@link 
SqlTypeFamily}, optionally with complex types
+ * that are accepted too, and for {@link SqlTypeFamily#NUMERIC} operands, 
whether character strings are accepted by
+ * casting them to numbers. Instances are immutable.
+ */
+public final class OperandType
+{
+  private final SqlTypeFamily family;
+  private final ImmutableSet<ColumnType> complexTypes;
+  private final boolean coerceStrings;
+
+  private OperandType(
+      final SqlTypeFamily family,
+      final ImmutableSet<ColumnType> complexTypes,
+      final boolean coerceStrings
+  )
+  {
+    this.family = Preconditions.checkNotNull(family, "family");
+    this.complexTypes = complexTypes;
+    this.coerceStrings = coerceStrings;
+  }
+
+  public static OperandType of(final SqlTypeFamily family)
+  {
+    return new OperandType(family, ImmutableSet.of(), false);
+  }
+
+  public static OperandType numeric()
+  {
+    return of(SqlTypeFamily.NUMERIC);
+  }
+
+  /**
+   * Returns an operand type that also accepts the given complex types. 
Comparison uses
+   * {@link RowSignatures.ComplexSqlType#getColumnType()}, so it does not 
depend on nullability.
+   */
+  public OperandType orComplex(final ColumnType... types)
+  {
+    return new OperandType(

Review Comment:
   Rechecked the current head and all 22 changed files: orComplex now rejects 
ANY operands with the requested defensive exception. No remaining issue from 
this thread.
   
   <!-- mergelens:review -->



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