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>>
Examples:CREATE TABLE IF NOT EXISTS cycling.race_starts ( cyclist_name text PRIMARY KEY, rnumbers FROZEN<LIST<int>> );
CREATE TABLE IF NOT EXISTS cycling.race_winners ( cyclist_name FROZEN<fullname>, race_name text, race_position int, PRIMARY KEY (race_name, race_position) );
CREATE TABLE IF NOT EXISTS cycling.cyclist_races ( id UUID PRIMARY KEY, lastname text, firstname text, races list<FROZEN <race>> );