Skip to main content
Version: Latest-3.2

bitmap_union

Description

Calculates the bitmap union of a set of values after grouping. Common usage scenarios include calculating PV and UV.

Syntax

BITMAP BITMAP_UNION(BITMAP value)

Examples

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

Use this function with bitmap_count() to obtain the UV of a web page.

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

If user_id is an integer, the above query statement is equivalent to the following:

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

keyword

BITMAP_UNION, BITMAP