EXPLODE_BITMAP
Description
The explode_bitmap table function accepts a bitmap type data and maps each bit in the bitmap to a separate row.
It is commonly used to process bitmap data, expanding each element in the bitmap into a separate record. It should be used together with LATERAL VIEW.
explode_bitmap_outer is similar to explode_bitmap, but behaves differently when handling empty or NULL values. It allows records with empty or NULL bitmaps to exist and expands them into NULL rows in the result.
Syntax
EXPLODE_BITMAP(<bitmap>)
Parameters
<bitmap>BITMAPtype
Return Value
- Returns a row for each bit in
<bitmap>, with each row containing a bit value.
Usage Notes
- If the
<bitmap>parameter is not of typeBITMAP, an error will be reported.
Examples
- Prepare data
create table example(
k1 int
) properties(
"replication_num" = "1"
);
insert into example values(1); - Regular parameters
select k1, e1 from example lateral view explode_bitmap(bitmap_from_string("1,3,4,5,6,10")) t2 as e1 order by k1, e1;+------+------+
| k1 | e1 |
+------+------+
| 1 | 1 |
| 1 | 3 |
| 1 | 4 |
| 1 | 5 |
| 1 | 6 |
| 1 | 10 |
+------+------+ - Empty BITMAP
select k1, e1 from example lateral view explode_bitmap(bitmap_from_string("")) t2 as e1 order by k1, e1;Empty set (0.03 sec) - NULL parameter
select * from example lateral view explode_bitmap(NULL) t2 as c;Empty set (0.03 sec) - Non-array parameter
select * from example lateral view explode_bitmap('abc') t2 as c;ERROR 1105 (HY000): errCode = 2, detailMessage = Can not find the compatibility function signature: explode_bitmap(VARCHAR(3))