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 abc4483d0089c83925c03f73fc541cada6a3aff3 Author: Pxl <[email protected]> AuthorDate: Wed May 10 11:12:20 2023 +0800 [Bug](scan) forbiden push down in predicate when in_state->use_set is false (#19471) forbiden push down in predicate when in_state->use_set is false --- be/src/vec/exec/scan/vscan_node.cpp | 12 ++++++++++++ regression-test/data/query_p0/sql_functions/test_in_expr.out | 10 ++++++++++ .../suites/query_p0/sql_functions/test_in_expr.groovy | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/be/src/vec/exec/scan/vscan_node.cpp b/be/src/vec/exec/scan/vscan_node.cpp index 63d40d4952..ce80396fa6 100644 --- a/be/src/vec/exec/scan/vscan_node.cpp +++ b/be/src/vec/exec/scan/vscan_node.cpp @@ -662,6 +662,12 @@ Status VScanNode::_normalize_in_and_eq_predicate(VExpr* expr, VExprContext* expr InState* state = reinterpret_cast<InState*>( expr_ctx->fn_context(pred->fn_context_index()) ->get_function_state(FunctionContext::FRAGMENT_LOCAL)); + + // xx in (col, xx, xx) should not be push down + if (!state->use_set) { + return Status::OK(); + } + iter = state->hybrid_set->begin(); } @@ -737,6 +743,12 @@ Status VScanNode::_normalize_not_in_and_not_eq_predicate(VExpr* expr, VExprConte InState* state = reinterpret_cast<InState*>( expr_ctx->fn_context(pred->fn_context_index()) ->get_function_state(FunctionContext::FRAGMENT_LOCAL)); + + // xx in (col, xx, xx) should not be push down + if (!state->use_set) { + return Status::OK(); + } + HybridSetBase::IteratorBase* iter = state->hybrid_set->begin(); auto fn_name = std::string(""); if (!is_fixed_range && state->null_in_set) { diff --git a/regression-test/data/query_p0/sql_functions/test_in_expr.out b/regression-test/data/query_p0/sql_functions/test_in_expr.out index 31d6bb5b1a..c7f58848a5 100644 --- a/regression-test/data/query_p0/sql_functions/test_in_expr.out +++ b/regression-test/data/query_p0/sql_functions/test_in_expr.out @@ -53,3 +53,13 @@ a b d +-- !select -- +2 +3 +4 + +-- !select -- +2 +3 +4 + diff --git a/regression-test/suites/query_p0/sql_functions/test_in_expr.groovy b/regression-test/suites/query_p0/sql_functions/test_in_expr.groovy index 01cacef28e..a2424e4d82 100644 --- a/regression-test/suites/query_p0/sql_functions/test_in_expr.groovy +++ b/regression-test/suites/query_p0/sql_functions/test_in_expr.groovy @@ -115,4 +115,15 @@ suite("test_in_expr", "query") { sql """DROP TABLE IF EXISTS ${nullTableName}""" sql """DROP TABLE IF EXISTS ${notNullTableName}""" + // from https://github.com/apache/doris/issues/19374 + sql """DROP TABLE IF EXISTS t11""" + sql """ + CREATE TABLE t11(c0 CHAR(109) NOT NULL) DISTRIBUTED BY HASH (c0) BUCKETS 13 PROPERTIES ("replication_num" = "1"); + """ + sql """ + insert into t11 values ('1'), ('1'), ('2'), ('2'), ('3'), ('4'); + """ + + qt_select "select t11.c0 from t11 group by t11.c0 having not ('1' in (t11.c0)) order by t11.c0;" + qt_select "select t11.c0 from t11 group by t11.c0 having ('1' not in (t11.c0)) order by t11.c0;" } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
