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 49e8550e9aec93d3c8fdccdebc57ce14308bd534 Author: starocean999 <[email protected]> AuthorDate: Thu May 4 11:16:18 2023 +0800 [fix](planner) insubquery should always be converted to semi or anti join (#19240) --- .../src/main/java/org/apache/doris/analysis/StmtRewriter.java | 10 ++++++---- .../suites/correctness_p0/test_join_without_condition.groovy | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java index eae4c6e215..c0b3a14ae6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java @@ -808,11 +808,13 @@ public class StmtRewriter { if (expr instanceof ExistsPredicate) { joinOp = ((ExistsPredicate) expr).isNotExists() ? JoinOperator.LEFT_ANTI_JOIN : JoinOperator.LEFT_SEMI_JOIN; - } else if (expr instanceof InPredicate && joinConjunct instanceof FunctionCallExpr - && (((FunctionCallExpr) joinConjunct).getFnName().getFunction() - .equalsIgnoreCase(BITMAP_CONTAINS))) { + } else if (expr instanceof InPredicate && !(joinConjunct instanceof BitmapFilterPredicate)) { joinOp = ((InPredicate) expr).isNotIn() ? JoinOperator.LEFT_ANTI_JOIN : JoinOperator.LEFT_SEMI_JOIN; - isInBitmap = true; + if ((joinConjunct instanceof FunctionCallExpr + && (((FunctionCallExpr) joinConjunct).getFnName().getFunction() + .equalsIgnoreCase(BITMAP_CONTAINS)))) { + isInBitmap = true; + } } else { joinOp = JoinOperator.CROSS_JOIN; // We can equal the aggregate subquery using a cross join. All conjuncts diff --git a/regression-test/suites/correctness_p0/test_join_without_condition.groovy b/regression-test/suites/correctness_p0/test_join_without_condition.groovy index c56144757a..88f86e23c7 100644 --- a/regression-test/suites/correctness_p0/test_join_without_condition.groovy +++ b/regression-test/suites/correctness_p0/test_join_without_condition.groovy @@ -63,6 +63,12 @@ suite("test_join_without_condition") { order by a.a, b.a; """ + explain { + sql("select * from (select 1 id) t where (1 in (select a from test_join_without_condition_a))") + notContains "CROSS JOIN" + contains "LEFT SEMI JOIN" + } + sql """ drop table if exists test_join_without_condition_a; """ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
