From 9af7506d2ed4e3304bdd374316c5b3f42cad7e20 Mon Sep 17 00:00:00 2001 From: zhangstar333 <2561612514@qq.com> Date: Thu, 2 Nov 2023 18:00:20 +0800 Subject: [PATCH] [bug](bitmap) fix bitmap value not clear get wrong data --- .../aggregate_function_bitmap.h | 5 ++++- .../test_aggregate_all_functions.out | 17 +++++++++++++++++ .../test_aggregate_all_functions.groovy | 6 +++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/be/src/vec/aggregate_functions/aggregate_function_bitmap.h b/be/src/vec/aggregate_functions/aggregate_function_bitmap.h index b070bae8c1d544..418eef1b9b78d3 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_bitmap.h +++ b/be/src/vec/aggregate_functions/aggregate_function_bitmap.h @@ -141,7 +141,10 @@ struct AggregateFunctionBitmapData { void read(BufferReadable& buf) { DataTypeBitMap::deserialize_as_stream(value, buf); } - void reset() { is_first = true; } + void reset() { + is_first = true; + value.clear(); + } BitmapValue& get() { return value; } }; diff --git a/regression-test/data/nereids_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.out b/regression-test/data/nereids_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.out index 316252a3cd3a69..ac05bf4e2aa421 100644 --- a/regression-test/data/nereids_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.out +++ b/regression-test/data/nereids_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.out @@ -11,6 +11,15 @@ xian 100.0 beijing 100.0 xian 100.0 +-- !select_all1 -- +20220201 eleme \N 10001,72173389 +20220201 meituan \N 10000,10001,72173389 +20220202 eleme \N 10001,72173389 +20220203 meituan \N 10000,10001,72173389 + +-- !select_all2 -- +20220202 eleme \N 10001,72173389 + -- !bitmap_intersect -- 20220201 10001 20220202 10001 @@ -22,6 +31,14 @@ xian 100.0 -- !select5 -- 3 +-- !select6 -- +2 +3 + +-- !select7 -- +10000,10001,72173389 +10001,72173389 + -- !group_bitmap_xor -- 20220201 10000 20220202 10001 diff --git a/regression-test/suites/nereids_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.groovy b/regression-test/suites/nereids_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.groovy index 2c1553adef7403..5f3b1248d8abb2 100644 --- a/regression-test/suites/nereids_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.groovy +++ b/regression-test/suites/nereids_p0/sql_functions/aggregate_functions/test_aggregate_all_functions.groovy @@ -104,11 +104,15 @@ suite("test_aggregate_all_functions") { sql "insert into ${tableName_03} select dt,page,to_bitmap(user_id_int) user_id from ${tableName_04}" sql "insert into ${tableName_03} select dt,page,bitmap_hash(user_id_str) user_id from ${tableName_04}" + qt_select_all1 "select *, bitmap_to_string(user_id) from pv_bitmap order by 1,2;" + qt_select_all2 "select *, bitmap_to_string(user_id) from pv_bitmap where dt = 20220202 order by 1,2;" + qt_bitmap_intersect "select dt, bitmap_to_string(bitmap_intersect(user_id_bitmap)) from ${tableName_04} group by dt order by dt" qt_select4 "select bitmap_union_count(user_id) from ${tableName_03}" qt_select5 "select bitmap_count(bitmap_union(user_id)) FROM ${tableName_03}" - + qt_select6 "select bitmap_union_count(user_id) from ${tableName_03} group by page order by 1;" + qt_select7 "select bitmap_to_string(bitmap_union(user_id)) FROM ${tableName_03} group by page order by 1;" qt_group_bitmap_xor "select dt, bitmap_to_string(group_bitmap_xor(user_id_bitmap)) from ${tableName_04} group by dt order by dt" sql "DROP TABLE IF EXISTS ${tableName_03}"