Map, set, and list types (Go)
The Data API supports map, set, and list types (CQL collection types).
Map
Use the map type to store a typed set of key-value pairs represented as a JSON object.
When you define a map column, you specify the data type for the keys and values.
For an example defining a map column, see Create a table (Go).
When written to a table, maps are internally ordered by their keys, and they are returned in that order.
The following limitations apply:
-
No nested maps, such as
map<string,map<string,string>>. -
Maps are not supported in primary keys, indexes, or
filterclauses. -
Maps can have only
textorasciikeys. -
Frozen maps created in CQL (outside the Data API) aren’t accessible through the Data API. For more information, see Support for existing tables.
The Go client accepts maps, datatypes.SortedMap[K, V], or datatypes.LinkedMap[K, V].
It returns map[string][any] by default.
Set
Use the set type to store a typed collection of unique values represented as a JSON array.
When you define a set column, you specify the data type for the values.
For an example defining a set column, see Create a table (Go).
When written to a table, sets are ordered by their values.
The following limitations apply:
-
No nested sets.
-
Sets are not supported in primary keys, indexes, or
filterclauses. -
Frozen sets created in CQL (outside the Data API) aren’t accessible through the Data API. For more information, see Support for existing tables.
The Go client accepts slices or datatypes.Set[T].
It returns []any by default.
List
Use the list type to store a typed collection of ordered, non-unique values represented as a JSON array.
When you define a list column, you specify the data type for the values.
When written to a table, lists elements are ordered by their position in the list.
The following limitations apply:
-
No nested lists.
-
Lists are not supported in primary keys, indexes, or
filterclauses. -
Frozen lists created in CQL (outside the Data API) aren’t accessible through the Data API. For more information, see Support for existing tables.
The Go client accepts slices.
It returns []any by default.