Freezing collection types

A collection column is declared using the collection type, followed by another type.

A collection column is declared using the collection type, followed by another type, such as int or text, in angle brackets. For example, you can create a table having a set of text, integers, or other data type elements.

frozen<set<data_type>>

To nest a collection type, freeze the nested collection. For example, nest a set within a map:

map<frozen <set<int>>>

Indexes may be created on a collection column of any type.

Using frozen in a collection

Use frozen on a set, map, or list to serialize multiple components into a single value, frozen<collection_definition>. Non-frozen types allow updates to individual fields, but values in a frozen collection are treated like blobs, any upsert overwrites the entire value.

column_name collection_type<data_type, frozen<column_name>>

For example:

CREATE TABLE mykeyspace.users (
  id uuid PRIMARY KEY,
  name frozen <fullname>,
  direct_reports set<frozen <fullname>>,     // a collection set
  addresses map<text, frozen <address>>     // a collection map
  score set<frozen <set<int>>>              // a set with a nested frozen set
);