Skip to main content
Version: 3.2

to_bitmap

Description

The input is unsigned bigint with the value ranging from 0 to 18446744073709551615, and the output is bitmap containing this element. This function is mainly used for the stream load task to import integer fields into the bitmap field of the StarRocks table. For example:

cat data | curl --location-trusted -u user:passwd -T - \
-H "columns: dt,page,user_id, user_id=to_bitmap(user_id)" \
http://host:8410/api/test/testDb/_stream_load

Syntax

BITMAP TO_BITMAP(expr)

Examples

MySQL > select bitmap_count(to_bitmap(10));
+-----------------------------+
| bitmap_count(to_bitmap(10)) |
+-----------------------------+
| 1 |
+-----------------------------+

select bitmap_to_string(to_bitmap(10));
+---------------------------------+
| bitmap_to_string(to_bitmap(10)) |
+---------------------------------+
| 10 |
+---------------------------------+

select bitmap_to_string(to_bitmap(-5));
+---------------------------------+
| bitmap_to_string(to_bitmap(-5)) |
+---------------------------------+
| NULL |
+---------------------------------+

select bitmap_to_string(to_bitmap(null));
+-----------------------------------+
| bitmap_to_string(to_bitmap(NULL)) |
+-----------------------------------+
| NULL |
+-----------------------------------+

keyword

TO_BITMAP,BITMAP