跳到主要内容
跳到主要内容

explode_bitmap

explode_bitmap

description

表函数,需配合 Lateral View 使用。

展开一个bitmap类型。

syntax

explode_bitmap(bitmap)

example

原表数据:

mysql> select k1 from example1 order by k1;
+------+
| k1 |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
+------+

Lateral View:

mysql> select k1, e1 from example1 lateral view explode_bitmap(bitmap_empty()) tmp1 as e1 order by k1, e1;
Empty set

mysql> select k1, e1 from example1 lateral view explode_bitmap(bitmap_from_string("1")) tmp1 as e1 order by k1, e1;
+------+------+
| k1 | e1 |
+------+------+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |
| 6 | 1 |
+------+------+

mysql> select k1, e1 from example1 lateral view explode_bitmap(bitmap_from_string("1,2")) tmp1 as e1 order by k1, e1;
+------+------+
| k1 | e1 |
+------+------+
| 1 | 1 |
| 1 | 2 |
| 2 | 1 |
| 2 | 2 |
| 3 | 1 |
| 3 | 2 |
| 4 | 1 |
| 4 | 2 |
| 5 | 1 |
| 5 | 2 |
| 6 | 1 |
| 6 | 2 |
+------+------+

mysql> select k1, e1 from example1 lateral view explode_bitmap(bitmap_from_string("1,1000")) tmp1 as e1 order by k1, e1;
+------+------+
| k1 | e1 |
+------+------+
| 1 | 1 |
| 1 | 1000 |
| 2 | 1 |
| 2 | 1000 |
| 3 | 1 |
| 3 | 1000 |
| 4 | 1 |
| 4 | 1000 |
| 5 | 1 |
| 5 | 1000 |
| 6 | 1 |
| 6 | 1000 |
+------+------+

mysql> select k1, e1, e2 from example1
lateral view explode_bitmap(bitmap_from_string("1,1000")) tmp1 as e1
lateral view explode_split("a,b", ",") tmp2 as e2 order by k1, e1, e2;
+------+------+------+
| k1 | e1 | e2 |
+------+------+------+
| 1 | 1 | a |
| 1 | 1 | b |
| 1 | 1000 | a |
| 1 | 1000 | b |
| 2 | 1 | a |
| 2 | 1 | b |
| 2 | 1000 | a |
| 2 | 1000 | b |
| 3 | 1 | a |
| 3 | 1 | b |
| 3 | 1000 | a |
| 3 | 1000 | b |
| 4 | 1 | a |
| 4 | 1 | b |
| 4 | 1000 | a |
| 4 | 1000 | b |
| 5 | 1 | a |
| 5 | 1 | b |
| 5 | 1000 | a |
| 5 | 1000 | b |
| 6 | 1 | a |
| 6 | 1 | b |
| 6 | 1000 | a |
| 6 | 1000 | b |
+------+------+------+

keywords

explode,bitmap,explode_bitmap