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

zstan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new f88149ba86c IGNITE-29253 Calcite. Fix erroneous implementation for 
RexUtils#buildHashSearchBounds (#13792)
f88149ba86c is described below

commit f88149ba86cad12b3560c9a657e0b50bf61355d2
Author: Evgeniy Stanilovskiy <[email protected]>
AuthorDate: Thu Nov 5 11:37:35 2026 +0300

    IGNITE-29253 Calcite. Fix erroneous implementation for 
RexUtils#buildHashSearchBounds (#13792)
---
 .../processors/query/calcite/util/RexUtils.java       |  6 +++---
 .../calcite/integration/SelectByKeyFieldTest.java     | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/RexUtils.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/RexUtils.java
index 180090141d3..ab8ba0bbd90 100644
--- 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/RexUtils.java
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/util/RexUtils.java
@@ -302,6 +302,9 @@ public class RexUtils {
             if (F.isEmpty(collFldPreds))
                 break;
 
+            if (mapping != null)
+                fldIdx = mapping.getSourceOpt(fldIdx);
+
             for (RexCall pred : collFldPreds) {
                 if (pred.getOperator().kind != SqlKind.EQUALS && 
pred.getOperator().kind != IS_NOT_DISTINCT_FROM) {
                     if (ignoreNotEqualPreds)
@@ -313,9 +316,6 @@ public class RexUtils {
                 if (bounds == null)
                     bounds = Arrays.asList(new SearchBounds[types.size()]);
 
-                if (mapping != null)
-                    fldIdx = mapping.getSourceOpt(fldIdx);
-
                 bounds.set(fldIdx, new ExactBounds(pred,
                     makeCast(builder(cluster), 
removeCast(pred.operands.get(1)), types.get(fldIdx))));
             }
diff --git 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectByKeyFieldTest.java
 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectByKeyFieldTest.java
index e5c1ee8dcb9..de92599ea47 100644
--- 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectByKeyFieldTest.java
+++ 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SelectByKeyFieldTest.java
@@ -108,6 +108,25 @@ public class SelectByKeyFieldTest extends 
AbstractBasicIntegrationTest {
             .check();
     }
 
+    /** */
+    @Test
+    public void testCompositePkSearchByPartOfKeyWithCorrelatedPredicate() {
+        sql("create table PUBLIC.PERSON(id int, name varchar, surname varchar, 
age int, primary key(id, name))");
+        sql("create table PUBLIC.ORG(id int primary key, name varchar)");
+
+        for (int i = 0; i < 10; i++) {
+            sql("insert into PUBLIC.PERSON(id, name, surname, age) values (?, 
?, ?, ?)", i, "foo" + i, "bar" + i, 18 + i);
+            sql("insert into PUBLIC.ORG(id, name) values (?, ?)", i, "org" + 
i);
+        }
+
+        // Correlated join pushes the second equality on the key column into 
the scan of PERSON.
+        assertQuery("select /*+ CNL_JOIN */ p.surname, o.name from 
PUBLIC.PERSON p join PUBLIC.ORG o on p.id = o.id " +
+            "where p.id = ?")
+            .withParams(6)
+            .returns("bar6", "org6")
+            .check();
+    }
+
     /** */
     @Test
     public void testCompositePkAfterAddColumn() {

Reply via email to