VeloDB Cloud
SQL Manual
Functions
bitmap-functions
bitmap_from_string

bitmap_from_string

Description

Syntax:

BITMAP BITMAP_FROM_STRING(VARCHAR input)

This function converts a string into a bitmap. The input string should be a group of unsigned bigint numbers separated by ",". (The numbers range from 0 to 18446744073709551615.) For example, the input string "0, 1, 2" will be converted to a bitmap with bit 0, 1, 2 being set. If input string is invalid, it will return NULL.

Example

mysql> select bitmap_to_string(bitmap_empty());
+----------------------------------+
| bitmap_to_string(bitmap_empty()) |
+----------------------------------+
|                                  |
+----------------------------------+

mysql> select bitmap_to_string(bitmap_from_string("0, 1, 2"));
+-------------------------------------------------+
| bitmap_to_string(bitmap_from_string('0, 1, 2')) |
+-------------------------------------------------+
| 0,1,2                                           |
+-------------------------------------------------+

mysql> select bitmap_from_string("-1, 0, 1, 2");
+-----------------------------------+
| bitmap_from_string('-1, 0, 1, 2') |
+-----------------------------------+
| NULL                              |
+-----------------------------------+

mysql> select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615"));
+--------------------------------------------------------------------+
| bitmap_to_string(bitmap_from_string('0, 1, 18446744073709551615')) |
+--------------------------------------------------------------------+
| 0,1,18446744073709551615                                           |
+--------------------------------------------------------------------+

Keywords

BITMAP_FROM_STRING,BITMAP