STRUCT type
Applies to:  Databricks SQL 
 Databricks Runtime
Represents values with the structure described by a sequence of fields.
Syntax
STRUCT < [fieldName [:] fieldType [NOT NULL] [COLLATE collationName] [COMMENT str] [, …] ] >
- 
fieldName: An identifier naming the field. The names need not be unique. - 
fieldType: Any data type. - 
NOT NULL: When specified, the struct guarantees that the value of this field is neverNULL. - 
COLLATEcollationName: This optionally specifies the collation to use for afieldTypeofSTRING.If not specified the collation is inherited from the context in which the
STRUCTis defined:- Within a 
CREATEorALTERof aTABLE,VIEW, orFUNCTION, the default collation matches the default collation of thatTABLE,VIEW, orFUNCTION. - Within the context of a top level UPDATE , DELETE, INSERT, MERGE or query statement the default collation is 
UTF8_BINARY. 
 - Within a 
 - 
COMMENT str: An optional string literal describing the field. 
Limits
The type supports any number of fields greater or equal to 0.
Literals
See struct function and named_struct function for details on how to produce literal array values.
Examples
SQL
> SELECT struct('Spark', 5);
  {Spark, 5}
> SELECT typeof(named_struct('Field1', 'Spark', 'Field2', 5));
  struct<Field1:string,Field2:int>
> SELECT typeof(struct('Spark', 5));
  struct<col1:string,col2:int>
> SELECT typeof(CAST(NULL AS STRUCT<Field1:INT NOT NULL COMMENT 'The first field.',Field2:ARRAY<INT>>));
  struct<Field1:int,Field2:array<int>>
> SELECT collation(cast(struct('hello')) AS STRUCT<name STRING COLLATE UNICODE_CI>).name);
 SYSTEM.BUILTIN.UNICODE_CI