TO_BITMAP
Descriptionβ
Converts an unsigned bigint to a Bitmap.
The input is an unsigned bigint with a value in the range 0 to 18446744073709551615, and the output is a Bitmap containing that element.
Syntaxβ
TO_BITMAP(<expr>)
Parametersβ
Parameter | Description |
---|---|
<expr> | An unsigned bigint or numbers represented as strings with a range of 0 to 18446744073709551615 |
Return Valueβ
A Bitmap containing the corresponding bigint.
Returns empty bitmap if the input value is not within the specified range.
Examplesβ
To convert an integer to a Bitmap and count the number of elements in the Bitmap:
select bitmap_to_string(to_bitmap(10)),bitmap_count(to_bitmap(10));
The result will be:
+---------------------------------+-----------------------------+
| bitmap_to_string(to_bitmap(10)) | bitmap_count(to_bitmap(10)) |
+---------------------------------+-----------------------------+
| 10 | 1 |
+---------------------------------+-----------------------------+
select bitmap_to_string(to_bitmap("123")),bitmap_count(to_bitmap("123"));
The result will be:
+------------------------------------+--------------------------------+
| bitmap_to_string(to_bitmap("123")) | bitmap_count(to_bitmap("123")) |
+------------------------------------+--------------------------------+
| 123 | 1 |
+------------------------------------+--------------------------------+
To convert a negative integer to a Bitmap, which is outside the valid range, and convert it to a string:
select bitmap_to_string(to_bitmap(-1)),bitmap_count(to_bitmap(-1));
The result will be:
+---------------------------------+-----------------------------+
| bitmap_to_string(to_bitmap(-1)) | bitmap_count(to_bitmap(-1)) |
+---------------------------------+-----------------------------+
| | 0 |
+---------------------------------+-----------------------------+
select bitmap_to_string(to_bitmap("123ABC")),bitmap_count(to_bitmap("123ABC"));
The result will be:
+---------------------------------------+-----------------------------------+
| bitmap_to_string(to_bitmap("123ABC")) | bitmap_count(to_bitmap("123ABC")) |
+---------------------------------------+-----------------------------------+
| | 0 |
+---------------------------------------+-----------------------------------+
select bitmap_to_string(to_bitmap(NULL)),bitmap_count(to_bitmap(NULL));
The result will be:
+-----------------------------------+-------------------------------+
| bitmap_to_string(to_bitmap(NULL)) | bitmap_count(to_bitmap(NULL)) |
+-----------------------------------+-------------------------------+
| | 0 |
+-----------------------------------+-------------------------------+