Map type
MAP(K, V)
stores key-value pairs. Here’s what K
and V
represent:
K
: The type of the Map keys. It can be string or integral types (i.e.,character varying
,smallint
,integer
, orbigint
). It must not beNULL
, and must be unique in the map.V
: The type of the Map values. It can be arbitrary type.
PUBLIC PREVIEW
This feature is currently in public preview, meaning it is nearing the final product but may not yet be fully stable. If you encounter any issues or have feedback, please reach out to us via our Slack channel. Your input is valuable in helping us improve this feature. For more details, see our Public Preview Feature List.
Define a map
To create a map with VARCHAR
keys and INTEGER
values, use the statement below.
Alternatively, it can be constructed from two arrays with map_from_key_values
or from an array of key-value pairs with map_from_entries
.
The following statement defines a table x
that has a MAP(VARCHAR, INTEGER)
column.
Access data in a map
Use bracket notation to access the value of a key.
Modify data in a map
Use map_insert
to insert or overwrite a key-value pair into a map.
Map functions and operators
For the full list of map functions and operators, see Map functions and operators.
Was this page helpful?