NobiGo commented on code in PR #3846:
URL: https://github.com/apache/calcite/pull/3846#discussion_r1671761045


##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -596,50 +598,63 @@ public static SqlOperandTypeChecker variadic(
       };
 
   /** Operand type-checking strategy that the first argument is of string type,
-   * and the remaining arguments can be of string or array of string type. */
-  public static final SqlOperandTypeChecker STRING_FIRST_STRING_ARRAY_OPTIONAL 
=
-      new SqlOperandTypeChecker() {
-        @Override public boolean checkOperandTypes(
-            SqlCallBinding binding,
+   * and the remaining arguments can be any type. */
+  public static final SqlOperandTypeChecker STRING_FIRST_OBJECT_REPEAT =
+      new StringFirstAndRepeatOperandTypeChecker(
+          SqlOperandCountRanges.from(2), "(<STRING>(,<ANY>)+)") {
+        @Override public boolean checkRepeatOperandTypes(SqlCallBinding 
callBinding,
             boolean throwOnFailure) {
-          // Check first operand is String type
-          if (!STRING.checkSingleOperandType(binding, binding.operand(0), 0, 
throwOnFailure)) {
-            return false;
+          ImmutableList.Builder<SqlTypeFamily> builder = 
ImmutableList.builder();
+          for (int i = 0; i < callBinding.getOperandCount(); i++) {
+            TypeCoercion coercion = 
callBinding.getValidator().getTypeCoercion();
+            RelDataType operandType = callBinding.getOperandType(i);
+            RelDataType cast =
+                ((AbstractTypeCoercion) coercion).implicitCast(operandType, 
SqlTypeFamily.STRING);
+            SqlTypeFamily family =
+                cast != null ? SqlTypeFamily.STRING
+                    : operandType.getSqlTypeName().getFamily();
+            assert family != null;
+            builder.add(family);
           }
+          ImmutableList<SqlTypeFamily> families = builder.build();
+          return family(families).checkOperandTypes(callBinding, 
throwOnFailure);
+        }
+      };
+
+  /** Operand type-checking strategy that the first argument is of string type,
+   * and the remaining arguments can be of string or array of string type. */
+  public static final SqlOperandTypeChecker STRING_FIRST_STRING_ARRAY_REPEAT =

Review Comment:
   Ok. The code looks better



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

Reply via email to