[fix](bitmapfilter) fix core dump caused by bitmap filter (#15296)

Do not push down the bitmap filter to a non-integer column
This commit is contained in:
luozenglin
2022-12-23 16:42:45 +08:00
committed by GitHub
parent 8515a03ef9
commit 8a810cd554
5 changed files with 24 additions and 4 deletions

View File

@ -1392,8 +1392,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;

View File

@ -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;

View File

@ -551,7 +551,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) {

View File

@ -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

View File

@ -35,7 +35,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;"
@ -58,6 +58,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"