From a16680cf9146f0fe889e41f6d8147d04ac45ad06 Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:15:36 +0800 Subject: [PATCH] [fix](planner)fix bug of bound conjunct to wrong tuple (#28811) this fix bug introduced by #28656 --- .../src/main/java/org/apache/doris/analysis/Analyzer.java | 6 +++--- .../suites/correctness_p0/test_rand_filter.groovy | 6 ++++++ 2 files changed, 9 insertions(+), 3 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 3737093d02..649c19b488 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 @@ -1335,12 +1335,12 @@ public class Analyzer { public void registerConjuncts(Expr e, boolean fromHavingClause, List ids) throws AnalysisException { for (Expr conjunct : e.getConjuncts()) { registerConjunct(conjunct); - if (!e.isConstant()) { + if (!conjunct.isConstant()) { ArrayList tupleIds = Lists.newArrayList(); ArrayList slotIds = Lists.newArrayList(); - e.getIds(tupleIds, slotIds); + conjunct.getIds(tupleIds, slotIds); if (tupleIds.isEmpty() && slotIds.isEmpty()) { - e.setBoundTupleIds(ids); + conjunct.setBoundTupleIds(ids); } } if (ids != null) { diff --git a/regression-test/suites/correctness_p0/test_rand_filter.groovy b/regression-test/suites/correctness_p0/test_rand_filter.groovy index ccad3161ca..40f5e1fe20 100644 --- a/regression-test/suites/correctness_p0/test_rand_filter.groovy +++ b/regression-test/suites/correctness_p0/test_rand_filter.groovy @@ -32,5 +32,11 @@ suite("test_rand_filter") { sql("""select * from test_rand_filter_t where rand() < 0.5 union all select * from test_rand_filter_t where rand() > 0.3;""") notContains("AND") } + explain { + sql("""select * from test_rand_filter_t + union all (select * from test_rand_filter_t where rand() < 0.3) + union all (select * from test_rand_filter_t where a > 5 and rand() < 0.4);""") + notContains("rand() < 0.3 AND rand() < 0.4") + } sql """ DROP TABLE IF EXISTS test_rand_filter_t """ }