named_struct function (Databricks SQL)

Creates a struct with the specified field names and values.

Syntax

named_struct( {name1, val1} [, ...] )

Arguments

  • nameN: A STRING literal naming field N.

  • valN: An expression of any type specifying the value for field N.

Returns

A struct with field N matching the type of valN.

Examples

> SELECT named_struct('a', 1, 'b', 2, 'c', 3);
 { 1, 2, 3}