Returns a set of rows by un-nesting expr with numbering of positions.
In Databricks SQL and Databricks Runtime 16.1 and above this function supports named parameter invocation.
Syntax
posexplode(collection)
Arguments
collection: An ARRAY or MAP expression.
Returns
A set of rows composed of the position and the elements of the array or the keys and values of the map.
The columns produced by posexplode of an array are named pos and col.
The columns for a map are called pos, key and value.
If collection is NULL no rows are produced.
Applies to: Databricks Runtime 12.1 and earlier:
posexplode can only be placed in the SELECT list as the root of an expression or following a LATERAL VIEW.
When placing the function in the SELECT list there must be no other generator function in the same SELECT list or UNSUPPORTED_GENERATOR.MULTI_GENERATOR is raised.
Applies to: Databricks SQL Databricks Runtime 12.2 LTS and above: