

# Nested type
<a name="s_Nested-data-type"></a>

AWS Clean Rooms supports queries involving data with nested data types, specifically the AWS Glue STRUCT, ARRAY, and MAP column types. Only the custom analysis rule supports nested data types.

Notably, nested data types don't conform to the rigid, tabular structure of the relational data model of SQL databases. 

Nested data types contains tags that reference distinct entities within the data. They can contain complex values such as arrays, nested structures, and other complex structures that are associated with serialization formats, such as JSON. Nested data types support up to 1 MB of data for an individual nested data type field or object.

**Topics**
+ [ARRAY type](array_type.md)
+ [MAP type](map_type.md)
+ [STRUCT type](struct_type.md)
+ [Examples of nested data types](s_nested-data-type-examples.md)

# ARRAY type
<a name="array_type"></a>

Use the ARRAY type to represent values comprising a sequence of elements with the type of `elementType`. 

```
array(elementType, containsNull)
```

Use `containsNull` to indicate if elements in an ARRAY type can have `null` values.

# MAP type
<a name="map_type"></a>

Use the MAP type to represent values comprising a set of key-value pairs. 

```
map(keyType, valueType, valueContainsNull)
```

`keyType`: the data type of keys 

`valueType`: the data type of values

Keys aren't allowed to have `null` values. Use `valueContainsNull` to indicate if values of a MAP type value can have `null` values.

# STRUCT type
<a name="struct_type"></a>

Use the STRUCT type to represent values with the structure described by a sequence of StructFields (fields). 

```
struct(name, dataType, nullable)
```

StructField(name, dataType, nullable): Represents a field in a StructType. 

`dataType`: the data type a field

`name`: the name of a field

Use `nullable` to indicate if values of these fields can have `null` values.

# Examples of nested data types
<a name="s_nested-data-type-examples"></a>

For the `struct<given:varchar, family:varchar>` type, there are two attribute names: `given`, and `family`, each corresponding to a `varchar` value.

For the `array<varchar>` type, the array is specified as a list of `varchar`. 

The `array<struct<shipdate:timestamp, price:double>>` type refers to a list of elements with `struct<shipdate:timestamp, price:double>` type. 

The `map` data type behaves like an `array` of `structs`, where the attribute name for each element in the array is denoted by `key` and it maps to a `value`. 

**Example**  
For example, the `map<varchar(20), varchar(20)>` type is treated as `array<struct<key:varchar(20), value:varchar(20)>>`, where `key` and `value` refer to the attributes of the map in the underlying data.   
For information about how AWS Clean Rooms enables navigation into arrays and structures, see [Navigation](query-nested-data.md#navigation).  
For information about how AWS Clean Rooms enables iteration over arrays by navigating the array using the FROM clause of a query, see [Unnesting queries](query-nested-data.md#unnesting-queries).