BITMAP_OR_COUNT
更新时间:2025-10-16
描述
计算两个及以上输入 Bitmap 的并集,返回并集的元素个数。
语法
SQL
1bitmap_or_count(<bitmap1>, <bitmap2>, ..., <bitmapN>)
参数
| 参数 | 描述 |
|---|---|
<bitmap1> |
第一个 Bitmap |
<bitmap2> |
第二个 Bitmap |
| ... | ... |
<bitmapN> |
第 N 个 Bitmap |
返回值
多个 Bitmap 并集的元素个数。
如果有 Bitmap 为 NULL 则返回 NULL。
示例
计算一个非空 Bitmap 和一个空 Bitmap 的并集中的元素数量:
SQL
1select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_empty());
结果如下:
Text
1+--------------------------------------------------------------+
2| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_empty()) |
3+--------------------------------------------------------------+
4| 3 |
5+--------------------------------------------------------------+
计算两个相同 Bitmap 的并集中的元素数量:
SQL
1select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3'));
结果如下:
Text
1+---------------------------------------------------------------------------+
2| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) |
3+---------------------------------------------------------------------------+
4| 3 |
5+---------------------------------------------------------------------------+
计算两个不同 Bitmap 的并集中的元素数量:
SQL
1select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'));
结果如下:
Text
1+---------------------------------------------------------------------------+
2| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) |
3+---------------------------------------------------------------------------+
4| 5 |
5+---------------------------------------------------------------------------+
计算多个 Bitmap(包括一个空 Bitmap)的并集中的元素数量:
SQL
1select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), bitmap_empty());
结果如下:
Text
1+-----------------------------------------------------------------------------------------------------------+
2| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), bitmap_empty()) |
3+-----------------------------------------------------------------------------------------------------------+
4| 6 |
5+-----------------------------------------------------------------------------------------------------------+
计算多个 Bitmap(包括一个 NULL 值)的并集中的元素数量:
SQL
1select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), NULL);
结果如下:
Text
1+-------------------------------------------------------------------------------------------------+
2| bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), NULL) |
3+-------------------------------------------------------------------------------------------------+
4| NULL |
5+-------------------------------------------------------------------------------------------------+
