Converts Array a into a table that has two columns. The first column lists the position of each element in the array, starting from 0. The second column lists the elements.
Syntax
posexplode(array<T> <a>)Parameters
a: required. This parameter specifies an array. T in array<T> specifies the data type of the elements in the array. The elements can be of any data type.
Return value
A table is returned.
POSEXPLODE
SELECT posexplode(ARRAY('a','c','f','b'));Results returned:
+------------+------------+
| pos | val |
+------------+------------+
| 0 | a |
| 1 | c |
| 2 | f |
| 3 | b |
+------------+------------+Related functions
POSEXPLODE is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.