STRING_TO_BITMAP Function
Description
The STRING_TO_BITMAP function converts a comma-separated string to a bitmap.
Parameters
str: STRING type, a comma-separated integer string.
Return Type
Notes
- Returns
NULL if the string contains negative numbers or is not properly formatted.
Examples
- Convert a string to a bitmap
SELECT bitmap_to_string(string_to_bitmap('1,2,2'));
+---------------------------------------------+
| bitmap_to_string(string_to_bitmap('1,2,2')) |
+---------------------------------------------+
| 1,2 |
+---------------------------------------------+
- Convert a string with non-consecutive integers
SELECT bitmap_to_string(string_to_bitmap('1,3,5'));
+---------------------------------------------+
| bitmap_to_string(string_to_bitmap('1,3,5')) |
+---------------------------------------------+
| 1,3,5 |
+---------------------------------------------+
- Returns NULL when the string contains negative numbers
SELECT string_to_bitmap('1,2,-1');
+------------------------------+
| string_to_bitmap('1,2,-1') |
+------------------------------+
| NULL |
+------------------------------+