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

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit b2a5367124b28bbf6045339a850e8a322348fcbc
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed Feb 22 20:23:00 2023 +0800

    [fix](planner) bucket shuffle join is not recognized if the first table is 
a subquery (#16985)
    
    consider sql select *
    from
    (select * from test_1) a
    inner join
    (select * from test_2) b
    on a.id = b.id
    inner join
    (select * from test_3) c
    on a.id = c.id
    
    Because a.id is from a subquery, to find its source table, need use 
function getSrcSlotRef().
---
 .../src/main/java/org/apache/doris/planner/PlanNode.java    |  3 +++
 .../suites/correctness_p0/test_bucket_shuffle_join.groovy   | 13 +++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
index cc1a1aa981..093b3d61b3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
@@ -952,6 +952,9 @@ public abstract class PlanNode extends TreeNode<PlanNode> 
implements PlanStats {
     }
 
     public SlotRef findSrcSlotRef(SlotRef slotRef) {
+        if (slotRef.getSrcSlotRef() != null) {
+            slotRef = slotRef.getSrcSlotRef();
+        }
         if (slotRef.getTable() instanceof OlapTable) {
             return slotRef;
         }
diff --git 
a/regression-test/suites/correctness_p0/test_bucket_shuffle_join.groovy 
b/regression-test/suites/correctness_p0/test_bucket_shuffle_join.groovy
index febd57a353..429d4f18ad 100644
--- a/regression-test/suites/correctness_p0/test_bucket_shuffle_join.groovy
+++ b/regression-test/suites/correctness_p0/test_bucket_shuffle_join.groovy
@@ -78,4 +78,17 @@ suite("test_bucket_shuffle_join") {
         contains "4:VHASH JOIN\n  |  join op: INNER JOIN(BUCKET_SHUFFLE)"
         contains "2:VHASH JOIN\n  |  join op: INNER JOIN(BUCKET_SHUFFLE)"
     }
+
+    explain {
+        sql("""select a.id,a.name,b.id,b.name 
+                from (select * from test_colo1) a 
+                inner join 
+                (select * from test_colo2) b 
+                on a.id = b.id  and a.name = b.name and a.name = b.name
+                inner join 
+                (select * from test_colo3) c 
+                on a.id = c.id  and a.name = c.name and a.name = c.name""")
+        contains "4:VHASH JOIN\n  |  join op: INNER JOIN(BUCKET_SHUFFLE)"
+        contains "2:VHASH JOIN\n  |  join op: INNER JOIN(BUCKET_SHUFFLE)"
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to