VeloDB Cloud
SQL Manual
Functions
table-functions
explode

explode

Description

This is a table function that is used in combination with Lateral View.

It converts an array column to multiple rows. If array is null or empty, the returned explode_outer part will be NULL. will return NULL. Bothexplode and explode_outer keep the nested NULL elements of array.

Syntax:

explode(expr)
explode_outer(expr)

Example

mysql> set enable_vectorized_engine = true

mysql> select e1 from (select 1 k1) as t lateral view explode([1,2,3]) tmp1 as e1;
+------+
| e1   |
+------+
|    1 |
|    2 |
|    3 |
+------+

mysql> select e1 from (select 1 k1) as t lateral view explode_outer(null) tmp1 as e1;
+------+
| e1   |
+------+
| NULL |
+------+

mysql> select e1 from (select 1 k1) as t lateral view explode([]) tmp1 as e1;
Empty set (0.010 sec)

mysql> select e1 from (select 1 k1) as t lateral view explode([null,1,null]) tmp1 as e1;
+------+
| e1   |
+------+
| NULL |
|    1 |
| NULL |
+------+

mysql> select e1 from (select 1 k1) as t lateral view explode_outer([null,1,null]) tmp1 as e1;
+------+
| e1   |
+------+
| NULL |
|    1 |
| NULL |
+------+

Keywords

EXPLODE,EXPLODE_OUTER,ARRAY