blob: 36b4c480791d28e15b2ab471ed4c7b49a111d163 [file] [view]
---
{
"title": "BITMAP_TO_ARRAY",
"language": "en",
"description": "Converts a Bitmap into an Array."
}
---
## Description
Converts a Bitmap into an Array.
## Syntax
```sql
BITMAP_TO_ARRAY(<bitmap>)
```
## Parameters
| Parameter | Description |
|------------|---------------------------------|
| `<bitmap>` | A Bitmap type column or expression |
## Return Value
An array containing all the bit positions in the Bitmap.
Returns `NULL` if the Bitmap is `NULL`.
## Examples
To convert a `NULL` Bitmap to an array:
```sql
select bitmap_to_array(null);
```
The result will be:
```text
+------------------------+
| bitmap_to_array(NULL) |
+------------------------+
| NULL |
+------------------------+
```
To convert an empty Bitmap to an array:
```sql
select bitmap_to_array(bitmap_empty());
```
The result will be:
```text
+---------------------------------+
| bitmap_to_array(bitmap_empty()) |
+---------------------------------+
| [] |
+---------------------------------+
```
To convert a Bitmap with a single element to an array:
```sql
select bitmap_to_array(to_bitmap(1));
```
The result will be:
```text
+-------------------------------+
| bitmap_to_array(to_bitmap(1)) |
+-------------------------------+
| [1] |
+-------------------------------+
```
To convert a Bitmap with multiple elements to an array:
```sql
select bitmap_to_array(bitmap_from_string('1,2,3,4,5'));
```
The result will be:
```text
+--------------------------------------------------+
| bitmap_to_array(bitmap_from_string('1,2,3,4,5')) |
+--------------------------------------------------+
| [1, 2, 3, 4, 5] |
+--------------------------------------------------+
```