struct
function
Applies to: Databricks SQL Databricks Runtime
Creates a STRUCT
with the specified field values.
Syntax
struct(expr1 [, ...] )
Arguments
exprN
: An expression of any type.
Returns
A struct with fieldN
matching the type of exprN
.
If the arguments are named references, the names are used to name the field.
Otherwise, the fields are named colN
, where N
is the position of the field in the struct.
Examples
> 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, 3);
{"col1":1,"col2":2,"col3":3}
Related functions
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for