> ## Documentation Index
> Fetch the complete documentation index at: https://docs.risingwave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Map functions and operators

## Map functions

### `map_access`

Returns the value of the map for the given key. Returns null if the key is not found.

```sql theme={null}
map_access ( map, key ) → value
```

```sql theme={null}
map_access(MAP{1:100,2:200}, 1) -> 100
map_access(MAP{1:100,2:200}, 3) -> null
```

### `map_cat`

Concatenates two maps. If the same key is present in both maps, the value from the second map is used.

```sql theme={null}
map_cat ( map, map ) → map
```

```sql theme={null}
map_cat (MAP{1:100,2:200}, MAP{2:201,3:300}) -> {1:100,2:201,3:300}
```

### `map_contains`

Returns true if the map contains the given key, false otherwise.

```sql theme={null}
map_contains ( map, key ) → boolean
```

```sql theme={null}
map_contains(MAP{1:100,2:200}, 1) -> true
map_contains(MAP{1:100,2:200}, 3) -> false
```

### `map_delete`

Deletes a key-value pair from the map. No-op if the key is not found.

```sql theme={null}
map_delete ( map, key ) → map
```

```sql theme={null}
map_delete(MAP{1:100,2:200}, 1) -> {2:200}
map_delete(MAP{1:100,2:200}, 3) -> {1:100,2:200}
```

### `map_entries` / `map_keys` / `map_values`

Returns an array of key-value pairs, keys, or values of the map.

```sql theme={null}
map_entries ( map ) → array
map_keys ( map ) → array
map_values ( map ) → array
```

```sql theme={null}
map_entries(MAP{1:100,2:200}) -> array[row(1,100),row(2,200)]
map_keys(MAP{1:100,2:200}) -> array[1,2]
map_values(MAP{1:100,2:200}) -> array[100,200]
```

### `map_filter`

<Note>
  Added in v2.5.0. It is currently in **[technical preview](/changelog/product-lifecycle#product-release-lifecycle)** stage.
</Note>

Filters a map using a lambda function and returns key-value pairs that satisfy the condition.

```sql theme={null}
map_filter ( map, function ) → map
```

```sql theme={null}
map_filter(MAP{'a':1, 'b':2, 'c':3}, |k, v| v > 1) -> {b:2,c:3}
```

### `map_from_entries`

Constructs a map from an array of key-value pairs.

```sql theme={null}
map_from_entries ( array ) → map
```

```sql theme={null}
map_from_entries(array[row('key1',1), row('key2',2), row('key3',3)]) -> {key1:1,key2:2,key3:3}
```

### `map_from_key_values`

Constructs a map from an array of keys and an array of values.

```sql theme={null}
map_from_key_values ( array, array ) → map
```

```sql theme={null}
map_from_key_values(array['key1','key2','key3'], array[1,2,3]) -> {key1:1,key2:2,key3:3}
```

### `map_length`

Returns the number of key-value pairs in the map.

```sql theme={null}
map_length ( map ) → int
```

```sql theme={null}
map_length(MAP{1:100,2:200}) -> 2
```

### `map_insert`

Inserts a key-value pair into the map. If the key is already present, the value is updated.

```sql theme={null}
map_insert ( map, key, value ) → map
```

```sql theme={null}
map_insert(MAP{1:100,2:200}, 3, 300) -> {1:100,2:200,3:300}
map_insert(MAP{1:100,2:200}, 1, 101) -> {2:200,1:101}
```

## Map operators

### `map [key] -> value`

Alias of `map_access`.

```sql theme={null}
MAP{1:100,2:200}[1] → 100
MAP{1:100,2:200}[3] → null
```
