This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/dev-1.1.2 by this push:
new d10a8690bd [fix](planner)push constant expr in predicate to outer
join's other conjuncts by mistake (#11527)
d10a8690bd is described below
commit d10a8690bdf5e0d32a96d3e3deb5ad31a17bfbe6
Author: morrySnow <[email protected]>
AuthorDate: Mon Aug 8 20:56:08 2022 +0800
[fix](planner)push constant expr in predicate to outer join's other
conjuncts by mistake (#11527)
constant expr in predicate should not be pushed to outer join's other
conjuncts
---
.../apache/doris/planner/SingleNodePlanner.java | 8 +--
.../test_constant_push_down_through_outer_join.out | 3 ++
...st_constant_push_down_through_outer_join.groovy | 61 ++++++++++++++++++++++
3 files changed, 68 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
index c804ed624f..305a44fe4e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
@@ -1545,24 +1545,24 @@ public class SingleNodePlanner {
// Conjuncts will be assigned to the lowest outer join node or
non-outer join's leaf children.
for (int i = select.getTableRefs().size(); i > 1; i--) {
final TableRef joinInnerChild =
select.getTableRefs().get(i - 1);
+ final TableRef joinOuterChild =
select.getTableRefs().get(i - 2);
if (!joinInnerChild.getJoinOp().isOuterJoin()) {
- // lowest join is't outer join.
+ // lowest join isn't outer join.
if (i == 2) {
// Register constant for inner.
viewAnalyzer.registerConjuncts(newConjuncts,
joinInnerChild.getDesc().getId().asList());
// Register constant for outer.
- final TableRef joinOuterChild =
select.getTableRefs().get(0);
final List<Expr> cloneConjuncts =
cloneExprs(newConjuncts);
viewAnalyzer.registerConjuncts(cloneConjuncts,
joinOuterChild.getDesc().getId().asList());
}
continue;
}
- viewAnalyzer.registerOnClauseConjuncts(newConjuncts,
joinInnerChild);
+ viewAnalyzer.registerConjuncts(newConjuncts,
joinOuterChild.getId());
break;
}
} else {
Preconditions.checkArgument(select.getTableRefs().size() == 1);
- viewAnalyzer.registerConjuncts(newConjuncts,
select.getTableRefs().get(0).getDesc().getId().asList());
+ viewAnalyzer.registerConjuncts(newConjuncts,
select.getTableRefs().get(0).getId());
}
} else {
Preconditions.checkArgument(stmt instanceof SetOperationStmt);
diff --git
a/regression-test/data/correctness/test_constant_push_down_through_outer_join.out
b/regression-test/data/correctness/test_constant_push_down_through_outer_join.out
new file mode 100644
index 0000000000..f958424e65
--- /dev/null
+++
b/regression-test/data/correctness/test_constant_push_down_through_outer_join.out
@@ -0,0 +1,3 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !select --
+
diff --git
a/regression-test/suites/correctness/test_constant_push_down_through_outer_join.groovy
b/regression-test/suites/correctness/test_constant_push_down_through_outer_join.groovy
new file mode 100644
index 0000000000..1343184219
--- /dev/null
+++
b/regression-test/suites/correctness/test_constant_push_down_through_outer_join.groovy
@@ -0,0 +1,61 @@
+// 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.
+
+ suite("constant_push_down_through_outer_join") {
+ sql """ DROP TABLE IF EXISTS wftest1 """
+ sql """ DROP TABLE IF EXISTS wftest2 """
+ sql """
+ CREATE TABLE `wftest1` (
+ `aa` varchar(200) NULL COMMENT "",
+ `bb` int NULL COMMENT ""
+ ) ENGINE=OLAP
+ UNIQUE KEY (`aa`) COMMENT "aa"
+ DISTRIBUTED BY HASH(`aa`) BUCKETS 3
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ )
+ """
+ sql """
+ CREATE TABLE `wftest2` (
+ `cc` varchar(200) NULL COMMENT "",
+ `dd` int NULL COMMENT ""
+ ) ENGINE=OLAP
+ UNIQUE KEY (`cc`)
+ COMMENT "OLAP"
+ DISTRIBUTED BY HASH(`cc`) BUCKETS 3
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ )
+ """
+
+ sql """
+ INSERT INTO wftest1 VALUES('a', 1), ('b', 1), ('c', 1);
+ """
+
+ sql """
+ INSERT INTO wftest2 VALUES('a', 1), ('b', 1), ('d', 1);
+ """
+
+ order_qt_select """
+ select t.* from (select * from wftest1 t1 left join wftest2 t2 on
t1.aa=t2.cc) t where dayofweek(current_date())=8;
+ """
+ }
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]