SQL
Struct Data Type
```sql
SELECT part1.part2.part3
FROM tbl;
```  
1. `part1` is a schema, `part2` is a table, `part3` is a column
2. `part1` is a table, `part2` is a column, `part3` is a property of that column
3. `part1` is a column, `part2` is a property of that column, `part3` is a property of that column  
Any extra parts (e.g., `.part4.part5`, etc.) are always treated as properties  
#### Creating Structs with the `row` Function {#docs:sql:data_types:struct::creating-structs-with-the-row-function}  
The `row` function can be used to automatically convert multiple columns to a single struct column.
When using `row` the keys will be empty strings allowing for easy insertion into a table with a struct column.
Columns, however, cannot be initialized with the `row` function, and must be explicitly named.
For example, inserting values into a struct column using the `row` function:  
```sql
CREATE TABLE t1 (s STRUCT(v VARCHAR, i INTEGER));
INSERT INTO t1 VALUES (row('a', 42));
SELECT * FROM t1;
```  
The table will contain a single entry:  
```sql
{'v': a, 'i': 42}
```  
The following produces the same result as above:  
```sql
CREATE TABLE t1 AS (
SELECT row('a', 42)::STRUCT(v VARCHAR, i INTEGER)
);
```  
Initializing a struct column with the `row` function will fail:  
```sql
CREATE TABLE t2 AS SELECT row('a');
```  
```console
Invalid Input Error: A table cannot be created from an unnamed struct
```  
When casting structs, the names of fields have to match. Therefore, the following query will fail:  
```sql
SELECT a::STRUCT(y INTEGER) AS b
FROM
(SELECT {'x': 42} AS a);
```  
```console
Mismatch Type Error: Type STRUCT(x INTEGER) does not match with STRUCT(y INTEGER). Cannot cast STRUCTs - element "x" in source struct was not found in target struct
```  
A workaround for this is to use [`struct_pack`](#::creating-structs) instead:  
```sql
SELECT struct_pack(y := a.x) AS b
FROM
(SELECT {'x': 42} AS a);
```  
The `row` function can be used to return unnamed structs. For example:  
```sql
SELECT row(x, x + 1, y) FROM (SELECT 1 AS x, 'a' AS y) AS s;
```  
This produces `(1, 2, a)`.  
If using multiple expressions when creating a struct, the `row` function is optional. The following query returns the same result as the previous one:  
```sql
SELECT (x, x + 1, y) AS s FROM (SELECT 1 AS x, 'a' AS y);
```