1. Add table function node 2. Add 3 table functions: explode_split, explode_bitmap and explode_json_array
157 lines
3.3 KiB
Markdown
157 lines
3.3 KiB
Markdown
---
|
|
{
|
|
"title": "explode_bitmap",
|
|
"language": "en"
|
|
}
|
|
---
|
|
|
|
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
or more contributor license agreements. See the NOTICE file
|
|
distributed with this work for additional information
|
|
regarding copyright ownership. The ASF licenses this file
|
|
to you under the Apache License, Version 2.0 (the
|
|
"License"); you may not use this file except in compliance
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the License is distributed on an
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, either express or implied. See the License for the
|
|
specific language governing permissions and limitations
|
|
under the License.
|
|
-->
|
|
|
|
# explode_bitmap
|
|
|
|
## description
|
|
|
|
Table functions must be used in conjunction with Lateral View.
|
|
|
|
Expand a bitmap type.
|
|
|
|
grammar:
|
|
|
|
```
|
|
explode_bitmap(bitmap)
|
|
```
|
|
|
|
## example
|
|
|
|
Original table data:
|
|
|
|
```
|
|
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;
|
|
+------+------+
|
|
| k1 | e1 |
|
|
+------+------+
|
|
| 1 | NULL |
|
|
| 2 | NULL |
|
|
| 3 | NULL |
|
|
| 4 | NULL |
|
|
| 5 | NULL |
|
|
| 6 | NULL |
|
|
+------+------+
|
|
|
|
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 |
|
|
+------+------+------+
|
|
```
|
|
|
|
## keyword
|
|
|
|
explode_bitmap |