inline table-valued generator function (Databricks SQL)

Explodes an array of structs into a table.

Syntax

inline(expr)

Arguments

  • expr: An ARRAY<STRUCT> expression.

Returns

A set of rows composed of the other expressions in the select list and the fields of the structs.

If expr is NULL no rows are produced.

inline can only be placed in the select list or a LATERAL VIEW. When placing the function in the select list there must be no other generator function in the same select list.

The columns produced by inline are named “col1”, “col2”, etc by default, but can be aliased using an alias tuple such as AS (myCol1, myCol2).

Examples

> SELECT inline(array(struct(1, 'a'), struct(2, 'b'))), 'Spark SQL';
 1  a Spark SQL
 2  b Spark SQL