struct function
Applies to:  Databricks SQL 
 Databricks Runtime
Creates a STRUCT with the specified field values.
Syntax
struct(expr1 [[AS] alias1] ) [, ...] )
Arguments
- exprN: An expression of any type.
- aliasN: An optional alias for the field.
Returns
A struct with fieldN matching the type of exprN.
The field names are determined by the following rules:
- If aliasNis specified, the field is namedaliasN.
- If exprNis a named reference, such as a column name, the field name is that name.
- Otherwise, the fields are named colN, whereNis the position of the field in the struct.
Examples
SQL
> SELECT struct(c1, c2, c3) FROM VALUES(1, 2, 3) AS T(c1, c2, c3);
 {"c1":1,"c2":2,"c3":3}
> SELECT struct(1, 2 AS two, 3);
 {"col1":1,"two":2,"col3":3}