Skip to content

Commit

Permalink
[bug](bitmap) fix bitmap value not clear get wrong data
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Nov 2, 2023
1 parent f883d1a commit 9af7506
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 4 additions & 1 deletion be/src/vec/aggregate_functions/aggregate_function_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 9af7506

Please sign in to comment.