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 024a848a66f0ec4dd1763a03a47ad92977e4f263 Author: luozenglin <37725793+luozeng...@users.noreply.github.com> AuthorDate: Fri Dec 23 16:42:45 2022 +0800 [fix](bitmapfilter) fix core dump caused by bitmap filter (#15296) Do not push down the bitmap filter to a non-integer column --- be/src/exprs/runtime_filter.cpp | 8 ++++++-- be/src/runtime/types.h | 5 +++++ be/src/vec/exec/scan/vscan_node.cpp | 2 +- regression-test/data/query_p0/join/test_bitmap_filter.out | 9 +++++++++ regression-test/suites/query_p0/join/test_bitmap_filter.groovy | 4 +++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/be/src/exprs/runtime_filter.cpp b/be/src/exprs/runtime_filter.cpp index d584f06d17..0444d3cc42 100644 --- a/be/src/exprs/runtime_filter.cpp +++ b/be/src/exprs/runtime_filter.cpp @@ -1325,8 +1325,12 @@ Status IRuntimeFilter::init_with_desc(const TRuntimeFilterDesc* desc, const TQue doris::vectorized::VExprContext* bitmap_target_ctx = nullptr; RETURN_IF_ERROR(doris::vectorized::VExpr::create_expr_tree(_pool, desc->bitmap_target_expr, &bitmap_target_ctx)); - auto* target_expr = doris::vectorized::VExpr::expr_without_cast(bitmap_target_ctx->root()); - params.column_return_type = const_cast<doris::vectorized::VExpr*>(target_expr)->type().type; + auto type = const_cast<vectorized::VExpr*>( + vectorized::VExpr::expr_without_cast(bitmap_target_ctx->root())) + ->type(); + // The bitmap filter evaluates only integers. + params.column_return_type = + type.is_integer_type() ? type.type : bitmap_target_ctx->root()->type().type; if (desc->__isset.bitmap_filter_not_in) { params.bitmap_filter_not_in = desc->bitmap_filter_not_in; diff --git a/be/src/runtime/types.h b/be/src/runtime/types.h index d4a30b3207..4f4c2ef0fe 100644 --- a/be/src/runtime/types.h +++ b/be/src/runtime/types.h @@ -160,6 +160,11 @@ struct TypeDescriptor { void to_protobuf(PTypeDesc* ptype) const; + bool is_integer_type() const { + return type == TYPE_TINYINT || type == TYPE_SMALLINT || type == TYPE_INT || + type == TYPE_BIGINT; + } + bool is_string_type() const { return type == TYPE_VARCHAR || type == TYPE_CHAR || type == TYPE_HLL || type == TYPE_OBJECT || type == TYPE_QUANTILE_STATE || type == TYPE_STRING; diff --git a/be/src/vec/exec/scan/vscan_node.cpp b/be/src/vec/exec/scan/vscan_node.cpp index cbd3a9e592..e7953c3703 100644 --- a/be/src/vec/exec/scan/vscan_node.cpp +++ b/be/src/vec/exec/scan/vscan_node.cpp @@ -501,7 +501,7 @@ Status VScanNode::_normalize_bloom_filter(VExpr* expr, VExprContext* expr_ctx, S Status VScanNode::_normalize_bitmap_filter(VExpr* expr, VExprContext* expr_ctx, SlotDescriptor* slot, PushDownType* pdt) { - if (TExprNodeType::BITMAP_PRED == expr->node_type()) { + if (TExprNodeType::BITMAP_PRED == expr->node_type() && expr->type().is_integer_type()) { DCHECK(expr->children().size() == 1); PushDownType temp_pdt = _should_push_down_bitmap_filter(); if (temp_pdt != PushDownType::UNACCEPTABLE) { diff --git a/regression-test/data/query_p0/join/test_bitmap_filter.out b/regression-test/data/query_p0/join/test_bitmap_filter.out index 83bcb3aed9..bf8be1dca2 100644 --- a/regression-test/data/query_p0/join/test_bitmap_filter.out +++ b/regression-test/data/query_p0/join/test_bitmap_filter.out @@ -66,3 +66,12 @@ -- !sql10 -- +-- !sql11 -- +1991-08-11 +1991-08-11 +2012-03-14 +2015-04-02 +2015-04-02 +2015-04-02 +2015-04-02 + diff --git a/regression-test/suites/query_p0/join/test_bitmap_filter.groovy b/regression-test/suites/query_p0/join/test_bitmap_filter.groovy index 90c0fe5f74..d73de718ac 100644 --- a/regression-test/suites/query_p0/join/test_bitmap_filter.groovy +++ b/regression-test/suites/query_p0/join/test_bitmap_filter.groovy @@ -36,7 +36,7 @@ suite("test_bitmap_filter", "query_p0") { "replication_allocation" = "tag.location.default: 1" ); """ - sql """insert into bitmap_table values (1, bitmap_from_string('1, 3, 5, 7, 9, 11, 13, 99'), + sql """insert into bitmap_table values (1, bitmap_from_string('1, 3, 5, 7, 9, 11, 13, 99, 19910811, 20150402'), bitmap_from_string('32767, 1985, 255, 789, 1991')),(2, bitmap_from_string('10, 11, 12, 13, 14'), bitmap_empty());""" qt_sql1 "select k1, k2 from ${tbl1} where k1 in (select k2 from ${tbl2}) order by k1;" @@ -59,6 +59,8 @@ suite("test_bitmap_filter", "query_p0") { qt_sql10 "select k1, k2 from (select 1 k1, 11 k2) t where k1 not in (select k2 from ${tbl2}) order by 1, 2;" + qt_sql11 "select k10 from ${tbl1} where cast(k10 as bigint) in (select bitmap_or(k2, to_bitmap(20120314)) from ${tbl2} b) order by 1;" + test { sql "select k1, k2 from ${tbl1} b1 where k1 in (select k2 from ${tbl2} b2 where b1.k2 = b2.k1) order by k1;" exception "In bitmap does not support correlated subquery" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org