BITMAP_UNION_COUNT
更新时间:2025-10-16
描述
计算输入 Bitmap 的并集,返回其基数
语法
SQL
1BITMAP_UNION_COUNT(<expr>)
参数
| 参数 | 说明 |
|---|---|
<expr> |
支持 BITMAP 的数据类型 |
返回值
返回 Bitmap 并集的大小,即去重后的元素个数
举例
SQL
1select dt,page,bitmap_to_string(user_id) from pv_bitmap;
Text
1+------+------+---------------------------+
2| dt | page | bitmap_to_string(user_id) |
3+------+------+---------------------------+
4| 1 | 100 | 100,200,300 |
5| 2 | 200 | 300 |
6+------+------+---------------------------+
计算 user_id 的去重值:
Plain Text
1select bitmap_union_count(user_id) from pv_bitmap;
Text
1+-------------------------------------+
2| bitmap_count(bitmap_union(user_id)) |
3+-------------------------------------+
4| 3 |
5+-------------------------------------+
