Skip to content

Commit 291a90b

Browse files
committed
[Bug](aggregate) fix bitmap_union return error result in query sql (apache#52033)
Problem Summary: the bitmap union maybe could call add_batch firstly, and the call add function, so if add_batch function not update is_first variable, it's will be loss data in union. ``` static void add(BitmapValue& res, const BitmapValue& data, bool& is_first) { if (UNLIKELY(is_first)) { res = data; is_first = false; } else { res |= data; } } static void add_batch(BitmapValue& res, std::vector<const BitmapValue*>& data, bool& is_first) { res.fastunion(data); is_first = false; // before not set this } ```
1 parent 8b59672 commit 291a90b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

be/src/vec/aggregate_functions/aggregate_function_bitmap.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct AggregateFunctionBitmapUnionOp {
5454
template <typename T>
5555
static void add(BitmapValue& res, const T& data, bool& is_first) {
5656
res.add(data);
57+
is_first = false;
5758
}
5859

5960
static void add(BitmapValue& res, const BitmapValue& data, bool& is_first) {
@@ -67,6 +68,9 @@ struct AggregateFunctionBitmapUnionOp {
6768

6869
static void add_batch(BitmapValue& res, std::vector<const BitmapValue*>& data, bool& is_first) {
6970
res.fastunion(data);
71+
// after fastunion, res myabe have many datas, so is_first should be false
72+
// then call add function will not reset res
73+
is_first = false;
7074
}
7175

7276
static void merge(BitmapValue& res, const BitmapValue& data, bool& is_first) {

0 commit comments

Comments
 (0)