mihaibudiu commented on code in PR #5232:
URL: https://github.com/apache/calcite/pull/5232#discussion_r3936825410


##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1499,6 +1501,78 @@ private 
RecordTypeWithOneFieldChecker(Predicate<SqlTypeName> predicate) {
       return !validationError;
     }
   }
+  /**
+   * Wraps a {@link SqlSingleOperandTypeChecker}, overriding only its
+   * {@link SqlOperandTypeChecker#getAllowedSignatures}. Needed because
+   * {@link CompositeOperandTypeChecker#withGenerator} always returns a plain
+   * {@link CompositeOperandTypeChecker}, which loses single-operand checking
+   * (see CALCITE-7749).
+   */
+  private static SqlSingleOperandTypeChecker withSignatureGenerator(
+      SqlSingleOperandTypeChecker checker,
+      BiFunction<SqlOperator, String, String> signatureGenerator) {
+    return new SqlSingleOperandTypeChecker() {
+      @Override public boolean checkSingleOperandType(SqlCallBinding 
callBinding,
+          SqlNode operand, int iFormalOperand, boolean throwOnFailure) {
+        // STRING_SAME_SAME-style checkers evaluate family membership AND
+        // cross-operand comparability together; there's no meaningful way to
+        // validate a single operand in isolation, so fall back to the full
+        // multi-operand check.
+        return checker.checkOperandTypes(callBinding, throwOnFailure);
+      }
+
+      @Override public boolean checkOperandTypes(SqlCallBinding callBinding,
+          boolean throwOnFailure) {
+        // Explicitly override rather than relying on the interface default
+        // (which would route through checkSingleOperandType(operand(0), 0)
+        // and only ever check the first operand).
+        return checker.checkOperandTypes(callBinding, throwOnFailure);
+      }
+
+      @Override public SqlOperandCountRange getOperandCountRange() {
+        return checker.getOperandCountRange();
+      }
+
+      @Override public boolean isOptional(int i) {
+        return checker.isOptional(i);
+      }
+
+      @Override public Consistency getConsistency() {
+        return checker.getConsistency();
+      }
+
+      @Override public String getAllowedSignatures(SqlOperator op, String 
opName) {
+        return signatureGenerator.apply(op, opName);
+      }
+    };
+  }
+
+  /**
+   * Builds a signature generator for STRING_SAME_SAME-style checkers, which

Review Comment:
   some of these comments can probably be made shorter and clearer.
   I would not mention 7749 twice.
   Maybe not even once?



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