-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Support bitmap_intersect #3571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support bitmap_intersect #3571
Conversation
Support aggregate function Bitmap Intersect, it is mainly used to take intersection of grouped data.
The function 'bitmap_intersect(expr)' calculates the intersection of bitmap columns and returns a bitmap object.
The defination is following:
FunctionName: bitmap_intersect,
InputType: bitmap,
OutputType: bitmap
The scenario is as follows:
Query which users satisfy the three tags a, b, and c at the same time.
```
select bitmap_to_string(bitmap_intersect(user_id)) from
(
select bitmap_union(user_id) user_id from bitmap_intersect_test
where tag in ('a', 'b', 'c')
group by tag
) a
```
Closed apache#3552.
Change-Id: I0d50c9bb6827f7319c4d854f621412343a3ece24
|
I will add sql-reference later. |
Co-authored-by: Mingyu Chen <morningman.cmy@gmail.com>
Change-Id: I4a815eaa5aac07ab75bb07e13f518da59cbef952
…bator-doris into bitmap_intersect Change-Id: I2f5bee7dd9a14f687881af8038dbbff17b6b6590
Change-Id: Ibb9bdb236d4d850e3d732bb55c441b7f8b80abba
Change-Id: I8bd03f5344eafc89a7d617d10399c848006bf590
| return; | ||
| } | ||
| // if dst is null, the src input is the first value | ||
| if (dst->is_null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would better add a UNLIKELY macros.
docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_intersect.md
Show resolved
Hide resolved
|
|
||
| // this is the read init function for bitmap_intersect | ||
| void BitmapFunctions::bitmap_intersect_init_real(FunctionContext* ctx, StringVal* dst) { | ||
| dst->is_null = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why initial result bitmap as null? it seems that it will return empty bitmap when result bitmap is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial result bitmap must be null. Otherwise, the intersection between dst and src will be empty.
|
@EmmyMiao87 Hi. 按照SQL标准,sum(null), min(null), max(null)结果为 null. count(null)为0. 所以 对于 bitmap_intersect,bitmap_union 返回bitmap的函数,输入全是null时,应该返回null, 在之前最开始的时候,我认为所有hll,bitmap的函数都不需要返回null,对于输入是null,我们返回empty bitmap 或者empty hll 即可。(it's my fault...) 所以目前bitmap_init, bitmap_serialize, bitmap_finalize的实现都是not nullable的。 |
Change-Id: I2d86d48dd5f5e836696b3d44620de41943052ee6
Change-Id: Ic21f0d500f464cee5d51e54858a18c89d080631b
imay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
kangkaisen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, LGTM
|
LGTM, +1 |
kangpinghuang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…fig disable auto start (apache#3571)
Support aggregate function Bitmap Intersect, it is mainly used to take intersection of grouped data.
The function 'bitmap_intersect(expr)' calculates the intersection of bitmap columns and returns a bitmap object.
The defination is following:
FunctionName: bitmap_intersect,
InputType: bitmap,
OutputType: bitmap
The scenario is as follows:
Query which users satisfy the three tags a, b, and c at the same time.
Closed #3552.
Change-Id: I0d50c9bb6827f7319c4d854f621412343a3ece24