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 in the public preview stage, meaning it’s nearing the final product but is not yet fully stable. If you encounter any issues or have feedback, please contact us through our Slack channel. Your input is valuable in helping us improve the feature. For more information, 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?