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

alexpl 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 2eebf5f8741 IGNITE-23345 SQL Calcite: Fix correlated nested loop LEFT 
join failure - Fixes #11565.
2eebf5f8741 is described below

commit 2eebf5f874131ffba29d99ba83a44cc08fee457e
Author: Aleksey Plekhanov <[email protected]>
AuthorDate: Fri Oct 4 09:20:49 2024 +0300

    IGNITE-23345 SQL Calcite: Fix correlated nested loop LEFT join failure - 
Fixes #11565.
    
    Signed-off-by: Aleksey Plekhanov <[email protected]>
---
 .../exec/rel/CorrelatedNestedLoopJoinNode.java        | 19 +++++++++++++------
 .../query/calcite/exec/rel/ExecutionTest.java         |  5 ++++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/CorrelatedNestedLoopJoinNode.java
 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/CorrelatedNestedLoopJoinNode.java
index c0e2bb2267c..b1d78912d49 100644
--- 
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/CorrelatedNestedLoopJoinNode.java
+++ 
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/CorrelatedNestedLoopJoinNode.java
@@ -127,7 +127,7 @@ public class CorrelatedNestedLoopJoinNode<Row> extends 
AbstractNode<Row> {
     /** {@inheritDoc} */
     @Override public void request(int rowsCnt) throws Exception {
         assert !F.isEmpty(sources()) && sources().size() == 2;
-        assert rowsCnt > 0 && requested == 0;
+        assert rowsCnt > 0 && requested == 0 : "rowsCnt=" + rowsCnt + ", 
requested=" + requested;
 
         checkState();
 
@@ -430,14 +430,21 @@ public class CorrelatedNestedLoopJoinNode<Row> extends 
AbstractNode<Row> {
 
                 int notMatchedIdx = leftMatched.nextClearBit(0);
 
-                while (requested > 0 && notMatchedIdx < leftInBuf.size()) {
-                    
downstream().push(handler.concat(leftInBuf.get(notMatchedIdx), rightEmptyRow));
+                state = State.IN_LOOP;
 
-                    requested--;
+                try {
+                    while (requested > 0 && notMatchedIdx < leftInBuf.size()) {
+                        requested--;
+
+                        
downstream().push(handler.concat(leftInBuf.get(notMatchedIdx), rightEmptyRow));
 
-                    leftMatched.set(notMatchedIdx);
+                        leftMatched.set(notMatchedIdx);
 
-                    notMatchedIdx = leftMatched.nextClearBit(notMatchedIdx + 
1);
+                        notMatchedIdx = leftMatched.nextClearBit(notMatchedIdx 
+ 1);
+                    }
+                }
+                finally {
+                    state = State.IDLE;
                 }
 
                 if (requested == 0 && notMatchedIdx < leftInBuf.size())
diff --git 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ExecutionTest.java
 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ExecutionTest.java
index e201c5cf2f4..6ca45427497 100644
--- 
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ExecutionTest.java
+++ 
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ExecutionTest.java
@@ -515,8 +515,11 @@ public class ExecutionTest extends AbstractExecutionTest {
 
                         join.register(Arrays.asList(left, right));
 
+                        FilterNode<Object[]> filter = new FilterNode<>(ctx, 
joinRowType, r -> true);
+                        filter.register(join);
+
                         RootNode<Object[]> root = new RootNode<>(ctx, 
joinRowType);
-                        root.register(join);
+                        root.register(filter);
 
                         int cnt = 0;
                         while (root.hasNext()) {

Reply via email to