BITMAP_OR_COUNT
Descriptionβ
Computes the union of two or more input Bitmaps and returns the count of elements in the union.
Syntaxβ
BITMAP_OR_COUNT(<bitmap1>, <bitmap2>, ..., <bitmapN>)
Parametersβ
Parameter | Description |
---|---|
<bitmap1> | The first Bitmap |
<bitmap2> | The second Bitmap |
... | ... |
<bitmapN> | The N-th Bitmap |
Return Valueβ
The count of elements in the union of multiple Bitmaps.
Examplesβ
To compute the count of elements in the union of a non-empty Bitmap and an empty Bitmap:
select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_empty()) res;
The result will be:
+------+
| res |
+------+
| 3 |
+------+
To compute the count of elements in the union of two identical Bitmaps:
select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) res;
The result will be:
+------+
| res |
+------+
| 3 |
+------+
To compute the count of elements in the union of two different Bitmaps:
select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) res;
The result will be:
+------+
| res |
+------+
| 5 |
+------+
To compute the count of elements in the union of multiple Bitmaps, including an empty Bitmap:
select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), bitmap_empty()) res;
The result will be:
+------+
| res |
+------+
| 6 |
+------+
To compute the count of elements in the union of multiple Bitmaps, including a NULL
value:
select bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'), to_bitmap(100), NULL) res;
The result will be:
+------+
| res |
+------+
| 6 |
+------+