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

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


The following commit(s) were added to refs/heads/master by this push:
     new 13134c1bfe [fix](fe)should check slot from both lhs and rhs of 
outputSmap of join node for colocate join (#16738)
13134c1bfe is described below

commit 13134c1bfe40368c6b01e3396b97b4e09a457429
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed Feb 15 12:44:20 2023 +0800

    [fix](fe)should check slot from both lhs and rhs of outputSmap of join node 
for colocate join (#16738)
    
    colocated join is depended on if the both side of the join conjuncts are 
simple column with same distribution policy etc. So the key is to figure out 
the original source column in scan node if there is one. To do that, we should 
check the slot from both lhs and rhs of outputSmap in join node.
---
 .../org/apache/doris/planner/HashJoinNode.java     |  6 ++-
 .../correctness_p0/test_colocate_join.groovy       | 46 +++++++++++++++++++++-
 2 files changed, 50 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
index c69a2310c5..0557e30b26 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
@@ -849,7 +849,11 @@ public class HashJoinNode extends JoinNodeBase {
             if (mappedExpr != null && mappedExpr instanceof SlotRef) {
                 return (SlotRef) mappedExpr;
             } else {
-                return null;
+                if (outputSmap.containsMappingFor(slotRef)) {
+                    return slotRef;
+                } else {
+                    return null;
+                }
             }
         } else {
             return slotRef;
diff --git a/regression-test/suites/correctness_p0/test_colocate_join.groovy 
b/regression-test/suites/correctness_p0/test_colocate_join.groovy
index 63d84f5b99..45e4e57bd3 100644
--- a/regression-test/suites/correctness_p0/test_colocate_join.groovy
+++ b/regression-test/suites/correctness_p0/test_colocate_join.groovy
@@ -19,6 +19,9 @@ suite("test_colocate_join") {
     sql """ DROP TABLE IF EXISTS `test_colo1` """
     sql """ DROP TABLE IF EXISTS `test_colo2` """
     sql """ DROP TABLE IF EXISTS `test_colo3` """
+    sql """ DROP TABLE IF EXISTS `test_colo4` """
+    sql """ DROP TABLE IF EXISTS `test_colo5` """
+
     sql """
         CREATE TABLE `test_colo1` (
         `id` varchar(64) NULL,
@@ -36,6 +39,7 @@ suite("test_colocate_join") {
         "disable_auto_compaction" = "false"
         );
     """
+
     sql """
         CREATE TABLE `test_colo2` (
         `id` varchar(64) NULL,
@@ -72,12 +76,52 @@ suite("test_colocate_join") {
         );
     """
 
+    sql """
+        CREATE TABLE `test_colo4` (
+        `id` varchar(64) NULL,
+        `name` varchar(64) NULL,
+        `age` int NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`id`,`name`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`id`,`name`) BUCKETS 4
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "colocate_with" = "group",
+        "in_memory" = "false",
+        "storage_format" = "V2",
+        "disable_auto_compaction" = "false"
+        );
+    """
+
+    sql """
+        CREATE TABLE `test_colo5` (
+        `id` varchar(64) NULL,
+        `name` varchar(64) NULL,
+        `age` int NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`id`,`name`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`id`,`name`) BUCKETS 4
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "colocate_with" = "group",
+        "in_memory" = "false",
+        "storage_format" = "V2",
+        "disable_auto_compaction" = "false"
+        );
+    """
+
     sql """insert into test_colo1 values('1','a',12);"""
     sql """insert into test_colo2 values('1','a',12);"""
     sql """insert into test_colo3 values('1','a',12);"""
+    sql """insert into test_colo4 values('1','a',12);"""
+    sql """insert into test_colo5 values('1','a',12);"""
 
     explain {
-        sql("select a.id,a.name,b.id,b.name,c.id,c.name from test_colo1 a 
inner join test_colo2 b on a.id = b.id and a.name = b.name inner join 
test_colo3 c on a.id=c.id and a.name= c.name")
+        sql("select * from test_colo1 a inner join test_colo2 b on a.id = b.id 
and a.name = b.name inner join test_colo3 c on a.id=c.id and a.name= c.name 
inner join test_colo4 d on a.id=d.id and a.name= d.name inner join test_colo5 e 
on a.id=e.id and a.name= e.name;")
+        contains "8:VHASH JOIN\n  |  join op: INNER JOIN(COLOCATE[])[]"
+        contains "6:VHASH JOIN\n  |  join op: INNER JOIN(COLOCATE[])[]"
         contains "4:VHASH JOIN\n  |  join op: INNER JOIN(COLOCATE[])[]"
         contains "2:VHASH JOIN\n  |  join op: INNER JOIN(COLOCATE[])[]"
     }


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

Reply via email to