This is an automated email from the ASF dual-hosted git repository.

mihaibudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit c2e213b07e5c5ff0b53617682061f60c0aaa7539
Author: Sean Broeder <[email protected]>
AuthorDate: Mon Aug 17 21:06:36 2026 -0700

    Shorten comments per review comments
---
 .../main/java/org/apache/calcite/sql/SqlUtil.java  |  8 ++----
 .../org/apache/calcite/test/SqlValidatorTest.java  | 29 ++++++----------------
 2 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/sql/SqlUtil.java 
b/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
index 7bc4c2a55d..1dba9d573e 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
@@ -558,12 +558,8 @@ public static SqlLiteral 
concatenateLiterals(List<SqlLiteral> lits) {
 
   private static Iterator<SqlOperator> filterOperatorRoutinesByKind(
       Iterator<SqlOperator> routines, final SqlKind sqlKind) {
-    // Map both sides through getFunctionKind() so a candidate can still match 
a call
-    // that is already bound to that very candidate (or an operator with the 
same
-    // requested kind) even when getFunctionKind() maps that kind to something 
else,
-    // e.g. SqlKind.POSITION/CHAR_LENGTH both map to OTHER_FUNCTION. Comparing 
the
-    // candidate's mapped kind against the call's raw, unmapped kind is 
asymmetric and
-    // can spuriously reject every candidate, including the operator being 
called.
+    // Mirror getFunctionKind() on both sides, or an operator whose kind maps 
to
+    // something else (e.g. POSITION -> OTHER_FUNCTION) can fail to match 
itself.
     final SqlKind sqlFunctionKind = sqlKind.getFunctionKind();
     return Iterators.filter(routines,
         operator -> requireNonNull(operator, "operator")
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
index 37c595c732..f0494539f0 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -1044,29 +1044,16 @@ void testDyadicCollateOperator() {
   }
 
   /** Test case for <a 
href="https://issues.apache.org/jira/browse/CALCITE-7724";>
-   * [CALCITE-7724] SqlUtil#lookupSubjectRoutines rejects a valid operator 
when two
-   * operator-table entries resolve to the same operator and that operator's
-   * {@link SqlKind} is remapped by {@link SqlKind#getFunctionKind()}</a>.
+   * [CALCITE-7724] SqlUtil#lookupSubjectRoutines rejects a valid operator 
when its
+   * SqlKind is remapped by SqlKind#getFunctionKind() and two operator-table 
entries
+   * resolve to it</a>.
    *
-   * <p>{@link SqlUtil#lookupSubjectRoutines} only reaches its "fourth pass"
-   * ({@code filterOperatorRoutinesByKind}) once at least two candidate 
operators survive
-   * the earlier passes - which happens whenever an operator table (or a chain 
of them)
-   * contains more than one entry for the same operator name, arity and 
category, e.g.
-   * because it is registered in two different operator tables that get 
chained together.
-   * That pass compares {@code candidate.getKind().getFunctionKind()} (mapped) 
against the
-   * call's already-bound, unmapped {@code SqlKind} - for any {@link SqlKind} 
that
-   * {@code getFunctionKind()} maps to something else (such as {@link 
SqlKind#POSITION} or
-   * the now-dedicated {@link SqlKind#CHAR_LENGTH}, both mapped to
-   * {@link SqlKind#OTHER_FUNCTION}), this comparison fails even when the 
candidate is the
-   * operator the call is already bound to - eliminating every candidate and 
causing a
-   * spurious "No match found for function signature" validation error for an 
otherwise
-   * perfectly valid call. */
+   * <p>The kind-based fourth pass in {@code filterOperatorRoutinesByKind} 
maps only
+   * the candidate's kind through {@code getFunctionKind()}, not the call's 
own kind -
+   * so an operator whose kind is remapped (e.g. {@link SqlKind#POSITION}) can 
fail to
+   * match itself once a second candidate for the same name exists. */
   @Test void testFunctionKindMismatchWithDuplicateOperatorTableEntry() {
-    // Chaining the standard operator table with itself is a minimal way to 
force two
-    // candidates for the same operator to reach the fourth pass; in practice 
this also
-    // happens with any two chained operator tables that both contribute an 
entry for the
-    // same builtin operator (which is how this was found - via a composite 
operator table
-    // with more than one contributor).
+    // Chaining the operator table with itself ensures that each appears twice.
     final SqlOperatorTable duplicated =
         SqlOperatorTables.chain(SqlStdOperatorTable.instance(), 
SqlStdOperatorTable.instance());
     expr("position('mouse' in 'house')")

Reply via email to