Files
doris/docs/en/sql-reference/sql-functions/bitmap-functions/bitmap_union.md
EmmyMiao87 0d66e6bd15 Support bitmap_intersect (#3571)
* Support bitmap_intersect

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 #3552.

* Add docs of bitmap_union and bitmap_intersect

* Support null of bitmap_intersect
2020-05-20 21:12:02 +08:00

1.6 KiB

title, language
title language
bitmap_union en

bitmap_union

description

Aggregate function, used to calculate the grouped bitmap union. Common usage scenarios such as: calculating PV, UV.

Syntax

BITMAP BITMAP_UNION(BITMAP value)

Enter a set of bitmap values, find the union of this set of bitmap values, and return.

example

mysql> select page_id, bitmap_union(user_id) from table group by page_id;

Combined with the bitmap_count function, the PV data of the web page can be obtained

mysql> select page_id, bitmap_count(bitmap_union(user_id)) from table group by page_id;

When the user_id field is int, the above query semantics is equivalent to

mysql> select page_id, count(distinct user_id) from table group by page_id;

keyword

BITMAP_UNION, BITMAP