Skip to main content

Map functions and operators

Subscript operator: []

The [] operator is used to retrieve the value corresponding to a given key from a map:

Map functions

cardinality

Returns the cardinality (size) of the map x.

element_at

Returns value for given key, or NULL if the key is not contained in the map.

map

Returns an empty map.
Returns a map created using the given key/value arrays.
See also map_agg() and multimap_agg() for creating a map as an aggregation.

map_from_entries

Returns a map created from the given array of entries.

multimap_from_entries

Returns a multimap created from the given array of entries. Each key can be associated with multiple values.

map_entries

Returns an array of all entries in the given map.

map_concat

Returns the union of all the given maps. If a key is found in multiple given maps, that key’s value in the resulting map comes from the last one of those maps.

map_filter

Constructs a map from those entries of map for which function returns true:

map_keys

Returns all the keys in the map x.

map_values

Returns all the values in the map x.

map_zip_with

Merges the two given maps into a single map by applying function to the pair of values with the same key. For keys only presented in one map, NULL will be passed as the value for the missing key.

transform_keys

Returns a map that applies function to each entry of map and transforms the keys:

transform_values

Returns a map that applies function to each entry of map and transforms the values: