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

morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 4e11eb73aee [fix](Nereids) colcoate node attr lost after merge 
fragment (#30818) (#30841)
4e11eb73aee is described below

commit 4e11eb73aee0d87eee9cebf8caec9793b5bb44e9
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Mon Feb 5 16:08:04 2024 +0800

    [fix](Nereids) colcoate node attr lost after merge fragment (#30818) 
(#30841)
    
    pick from master #30818
    commit id 3e4a2514e1aed741472dd43c77f09a230d2987f2
---
 .../glue/translator/PlanTranslatorContext.java     |   6 ++
 .../doris/planner/MultiCastPlanFragment.java       |   1 +
 .../org/apache/doris/planner/PlanFragment.java     |   2 +-
 .../colocate/test_multi_cast_colocate.out          | 103 ++++++++++++++++++++
 .../colocate/test_set_operation_colocate.out       |  10 ++
 .../colocate/test_multi_cast_colocate.groovy       |  59 ++++++++++++
 .../colocate/test_set_operation_colocate.groovy    | 104 +++++++++++++++++++++
 7 files changed, 284 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java
index e69b5ee8ef3..fb1f27f3330 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java
@@ -172,9 +172,15 @@ public class PlanTranslatorContext {
         slotIdToExprId.put(slotRef.getDesc().getId(), exprId);
     }
 
+    /**
+     * merge source fragment info into target fragment.
+     * include runtime filter info and fragment attribute.
+     */
     public void mergePlanFragment(PlanFragment srcFragment, PlanFragment 
targetFragment) {
         
srcFragment.getTargetRuntimeFilterIds().forEach(targetFragment::setTargetRuntimeFilterIds);
         
srcFragment.getBuilderRuntimeFilterIds().forEach(targetFragment::setBuilderRuntimeFilterIds);
+        
targetFragment.setHasColocatePlanNode(targetFragment.hasColocatePlanNode()
+                || srcFragment.hasColocatePlanNode());
         this.planFragments.remove(srcFragment);
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/MultiCastPlanFragment.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/MultiCastPlanFragment.java
index e52bbb05577..9c54bdb406c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/planner/MultiCastPlanFragment.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/planner/MultiCastPlanFragment.java
@@ -31,6 +31,7 @@ public class MultiCastPlanFragment extends PlanFragment {
     public MultiCastPlanFragment(PlanFragment planFragment) {
         super(planFragment.getFragmentId(), planFragment.getPlanRoot(), 
planFragment.getDataPartition(),
                 planFragment.getBuilderRuntimeFilterIds(), 
planFragment.getTargetRuntimeFilterIds());
+        this.hasColocatePlanNode = planFragment.hasColocatePlanNode;
         this.outputPartition = DataPartition.RANDOM;
         this.children.addAll(planFragment.getChildren());
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanFragment.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanFragment.java
index 471eccf14bb..26fe6c8d228 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanFragment.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanFragment.java
@@ -144,7 +144,7 @@ public class PlanFragment extends TreeNode<PlanFragment> {
     private Set<RuntimeFilterId> targetRuntimeFilterIds;
 
     // has colocate plan node
-    private boolean hasColocatePlanNode = false;
+    protected boolean hasColocatePlanNode = false;
 
     /**
      * C'tor for fragment with specific partition; the output is by default 
broadcast.
diff --git 
a/regression-test/data/nereids_p0/colocate/test_multi_cast_colocate.out 
b/regression-test/data/nereids_p0/colocate/test_multi_cast_colocate.out
new file mode 100644
index 00000000000..0656c42045f
--- /dev/null
+++ b/regression-test/data/nereids_p0/colocate/test_multi_cast_colocate.out
@@ -0,0 +1,103 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test --
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+
diff --git 
a/regression-test/data/nereids_p0/colocate/test_set_operation_colocate.out 
b/regression-test/data/nereids_p0/colocate/test_set_operation_colocate.out
new file mode 100644
index 00000000000..2e735a3b038
--- /dev/null
+++ b/regression-test/data/nereids_p0/colocate/test_set_operation_colocate.out
@@ -0,0 +1,10 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test --
+1
+1
+1
+1
+1
+1
+1
+
diff --git 
a/regression-test/suites/nereids_p0/colocate/test_multi_cast_colocate.groovy 
b/regression-test/suites/nereids_p0/colocate/test_multi_cast_colocate.groovy
new file mode 100644
index 00000000000..92cc3e8eb97
--- /dev/null
+++ b/regression-test/suites/nereids_p0/colocate/test_multi_cast_colocate.groovy
@@ -0,0 +1,59 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// this suite is for creating table with timestamp datatype in defferent
+// case. For example: 'year' and 'Year' datatype should also be valid in 
definition
+
+suite("test_multi_cast_colocate") {
+    sql 'set enable_nereids_planner=true'
+    sql 'set enable_fallback_to_original_planner=false'
+    sql 'set enable_nereids_dml=true'
+
+    sql """
+        drop table if exists test_multi_cast_colocate
+    """
+
+    sql """
+        create table test_multi_cast_colocate (
+            `c1` int,
+            `c2` varchar(10)   ,
+            `pk` int
+        ) engine=olap
+        distributed by hash(pk) buckets 10
+        properties("replication_num" = "1");
+    """
+
+    sql """
+        insert into test_multi_cast_colocate(pk,c1,c2) values 
(0,null,'m'),(1,1,"me"),(2,null,'p'),(3,null,"and"),(4,7,'v'),(5,3,"what"),(6,5,'j'),(7,null,"he's"),(8,null,'q'),(9,8,"like"),(10,null,"me"),(11,null,"from"),(12,4,'r'),(13,null,"now"),(14,null,'q'),(15,2,"me"),(16,6,'y'),(17,4,"on"),(18,null,'d'),(19,7,"really"),(20,2,"for"),(21,null,'a'),(22,9,'j'),(23,null,"tell"),(24,6,'f'),(25,7,'n'),(26,3,'g'),(27,null,"on"),(28,0,'l'),(29,2,'n'),(30,null,"her"),(31,null,"got"),(32,8,'i
 [...]
+    """
+
+    sql """
+        sync
+    """
+
+    qt_test """
+        WITH cte1 AS (
+            SELECT t1.`pk`
+            FROM test_multi_cast_colocate AS t1 LEFT SEMI
+                JOIN test_multi_cast_colocate AS alias1 ON t1.`pk` = 
alias1.`pk`
+        )
+        SELECT cte1.`pk` AS pk1
+        FROM cte1
+            FULL OUTER JOIN cte1 AS alias2 ON cte1.`pk` = alias2.`pk`
+        ORDER BY pk1
+    """
+}
diff --git 
a/regression-test/suites/nereids_p0/colocate/test_set_operation_colocate.groovy 
b/regression-test/suites/nereids_p0/colocate/test_set_operation_colocate.groovy
new file mode 100644
index 00000000000..c36d673b10b
--- /dev/null
+++ 
b/regression-test/suites/nereids_p0/colocate/test_set_operation_colocate.groovy
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// this suite is for creating table with timestamp datatype in defferent
+// case. For example: 'year' and 'Year' datatype should also be valid in 
definition
+
+suite("test_set_operation_colocate") {
+    sql 'set enable_nereids_planner=true'
+    sql 'set enable_fallback_to_original_planner=false'
+    sql 'set enable_nereids_dml=true'
+
+    sql """
+        drop table if exists test1
+    """
+
+    sql """
+        drop table if exists test2
+    """
+
+    sql """
+        drop table if exists test3
+    """
+
+    sql """
+        create table test1 (
+            `c1` int   ,
+            `c2` varchar(10)   ,
+            `pk` int
+        ) engine=olap
+        distributed by hash(pk) buckets 10
+        properties("replication_num" = "1");
+    """
+
+    sql """
+        insert into test1(pk,c1,c2) values 
(0,8,"yes"),(1,3,'y'),(2,3,"on"),(3,5,'f'),(4,null,'m'),(5,null,"really"),(6,null,"get");
+    """
+
+    sql """
+        create table test2 (
+            `c1` int  ,
+            `c2` varchar(10)   ,
+            `pk` int
+        ) engine=olap
+        distributed by hash(pk) buckets 10
+        properties("replication_num" = "1");
+    """
+
+    sql """
+        insert into test2(pk,c1,c2) values 
(0,null,"okay"),(1,8,'h'),(2,null,'x'),(3,3,'c'),(4,4,'i'),(5,null,"because"),(6,6,"yeah"),(7,7,'i'),(8,1,'z'),(9,null,'h'),(10,null,'x'),(11,7,'k'),(12,null,'n'),(13,8,'s'),(14,null,"I'll"),(15,null,"yeah"),(16,6,"was"),(17,null,"can"),(18,1,'a'),(19,null,'s'),(20,2,'n'),(21,4,"right"),(22,4,"were");
+    """
+
+    sql """
+        create table test3 (
+            `c1` int,
+            `c2` varchar(10)   ,
+            `pk` int
+        ) engine=olap
+        distributed by hash(pk) buckets 10
+        properties("replication_num" = "1");
+    """
+
+    sql """
+        insert into test3(pk,c1,c2) values (0,7,"have");
+    """
+
+    sql """
+        sync
+    """
+
+    qt_test """
+        SELECT COUNT () AS pk1
+        FROM (
+                (
+                    SELECT t1.`pk`
+                    FROM test1 AS t1
+                        FULL OUTER JOIN test1 AS alias1 ON t1.`pk` = 
alias1.`pk`
+                )
+                UNION
+                (
+                    SELECT t1.`pk`
+                    FROM test1 AS t1,
+                        test2 AS alias2
+                        INNER JOIN test3 AS alias3
+                    ORDER BY t1.pk
+                )
+            ) subq1
+        GROUP BY subq1.`pk`
+        ORDER BY 1;
+    """
+}


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

Reply via email to