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 6fa6f1a974c41bd4fc4b6fb1e9123007845d0f10 Author: Pxl <[email protected]> AuthorDate: Wed May 17 10:28:22 2023 +0800 [Bug](planner) fix unassigned conjunct assigned on wrong node (#19672) * fix unassigned conjunct assigned on wrong node --- .../main/java/org/apache/doris/analysis/Analyzer.java | 15 +++++++++++---- regression-test/data/query_p0/join/test_join.out | 2 ++ regression-test/suites/query_p0/join/test_join.groovy | 16 +++++++++++++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java index 4e3a75d2fd..9d37efd810 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java @@ -1354,10 +1354,10 @@ public class Analyzer { } if (e.isBoundByTupleIds(tupleIds) && !e.isAuxExpr() - && !globalState.assignedConjuncts.contains(e.getId()) + && (!globalState.assignedConjuncts.contains(e.getId()) || e.isConstant()) && ((inclOjConjuncts && !e.isConstant()) - || (!globalState.ojClauseByConjunct.containsKey(e.getId()) - && !globalState.sjClauseByConjunct.containsKey(e.getId())))) { + || (!globalState.ojClauseByConjunct.containsKey(e.getId()) + && !globalState.sjClauseByConjunct.containsKey(e.getId())))) { result.add(e); } } @@ -2391,7 +2391,14 @@ public class Analyzer { * Wrapper around getUnassignedConjuncts(List<TupleId> tupleIds). */ public List<Expr> getUnassignedConjuncts(PlanNode node) { - return getUnassignedConjuncts(node.getTblRefIds()); + // constant conjuncts should be push down to all leaf node. + // so we need remove constant conjuncts when expr is not a leaf node. + List<Expr> unassigned = getUnassignedConjuncts(node.getTblRefIds()); + if (!node.getChildren().isEmpty()) { + unassigned = unassigned.stream() + .filter(e -> !e.isConstant()).collect(Collectors.toList()); + } + return unassigned; } /** diff --git a/regression-test/data/query_p0/join/test_join.out b/regression-test/data/query_p0/join/test_join.out index 987bbf1ecb..d21704875a 100644 --- a/regression-test/data/query_p0/join/test_join.out +++ b/regression-test/data/query_p0/join/test_join.out @@ -2864,3 +2864,5 @@ false true true false false 14 15 +-- !test -- + diff --git a/regression-test/suites/query_p0/join/test_join.groovy b/regression-test/suites/query_p0/join/test_join.groovy index 806f56d2d2..10496caa27 100644 --- a/regression-test/suites/query_p0/join/test_join.groovy +++ b/regression-test/suites/query_p0/join/test_join.groovy @@ -1233,8 +1233,6 @@ suite("test_join", "query,p0") { qt_sql """select k1 from test right anti join baseall on false order by k1;""" // test bucket shuffle join, github issue #6171 - sql"""create database if not exists test_issue_6171""" - sql"""use test_issue_6171""" List table_list = ["T_DORIS_A", "T_DORIS_B", "T_DORIS_C", "T_DORIS_D", "T_DORIS_E"] List column_list = [",APPLY_CRCL bigint(19)", ",FACTOR_FIN_VALUE decimal(19,2),PRJT_ID bigint(19)", @@ -1253,5 +1251,17 @@ suite("test_join", "query,p0") { B.FACTOR_FIN_VALUE, D.limit_id desc;""" logger.info(ret.toString()) assertTrue(ret.toString().contains(" | join op: INNER JOIN(BROADCAST)")) - sql"""drop database test_issue_6171""" + + sql """ + CREATE TABLE t0(c0 BOOLEAN NOT NULL) DISTRIBUTED BY HASH (c0) BUCKETS 8 PROPERTIES ("replication_num" = "1"); + """ + sql """ + CREATE TABLE t1(c0 DATETIME NOT NULL) DISTRIBUTED BY HASH (c0) BUCKETS 9 PROPERTIES ("replication_num" = "1"); + """ + sql """INSERT INTO t1 (c0) VALUES (DATE '1970-02-15'), (DATE '1970-11-05'), (DATE '1970-07-10');""" + sql """INSERT INTO t1 (c0) VALUES (DATE '1970-04-04');""" + sql """INSERT INTO t1 (c0) VALUES (DATE '1970-09-06');""" + sql """INSERT INTO t0 (c0) VALUES (true);""" + sql """INSERT INTO t0 (c0) VALUES (false);""" + qt_test """SELECT t1.c0 FROM t1 RIGHT JOIN t0 ON true WHERE (abs(1)=0) GROUP BY t1.c0;""" } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
