This is an automated email from the ASF dual-hosted git repository.
morrysnow 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 3e4a2514e1a [fix](Nereids) colcoate node attr lost after merge
fragment (#30818)
3e4a2514e1a is described below
commit 3e4a2514e1aed741472dd43c77f09a230d2987f2
Author: morrySnow <[email protected]>
AuthorDate: Mon Feb 5 14:42:09 2024 +0800
[fix](Nereids) colcoate node attr lost after merge fragment (#30818)
---
.../glue/translator/PlanTranslatorContext.java | 8 ++
.../doris/planner/MultiCastPlanFragment.java | 2 +
.../org/apache/doris/planner/PlanFragment.java | 4 +-
.../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, 288 insertions(+), 2 deletions(-)
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 1aa98bb4924..df314d7f37a 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
@@ -212,9 +212,17 @@ public class PlanTranslatorContext {
exprIdToColumnRef.put(exprId, columnRefExpr);
}
+ /**
+ * 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());
+
targetFragment.setHasNullAwareLeftAntiJoin(targetFragment.isHasNullAwareLeftAntiJoin()
+ || srcFragment.isHasNullAwareLeftAntiJoin());
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..4b2258c8a22 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,8 @@ 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.hasNullAwareLeftAntiJoin = planFragment.hasNullAwareLeftAntiJoin;
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 d95343d0e53..f24c16561a1 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
@@ -147,9 +147,9 @@ public class PlanFragment extends TreeNode<PlanFragment> {
private int bucketNum;
// has colocate plan node
- private boolean hasColocatePlanNode = false;
+ protected boolean hasColocatePlanNode = false;
- private boolean hasNullAwareLeftAntiJoin = false;
+ protected boolean hasNullAwareLeftAntiJoin = false;
private TResultSinkType resultSinkType = TResultSinkType.MYSQL_PROTOCAL;
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: [email protected]
For additional commands, e-mail: [email protected]