# Chalk SQL Reference: Maps / Dictionaries
source: https://docs.chalk.ai/chalksql-docs#section-maps-/-dictionaries

## `all_keys_match(map, key)`
source: https://docs.chalk.ai/chalksql-docs#all_keys_match

Returns true if all keys in the `map` match the given predicate.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `($K) => bool`
  The map `key` to read or update. `K` is the key type of the input map.

## `any_keys_match(map, key)`
source: https://docs.chalk.ai/chalksql-docs#any_keys_match

Returns true if any `key` in the `map` matches the given predicate.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `($K) => bool`
  The map `key` to read or update. `K` is the key type of the input map.

## `any_values_match(map, key)`
source: https://docs.chalk.ai/chalksql-docs#any_values_match

Returns true if any value in the `map` matches the given predicate.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `($V) => bool`
  The map `key` to read or update. `V` is the value type of the input map.

## `map_contains(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_contains

Checks if a `map` contains any keys that match a given condition.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `($k) => bool`
  The map `key` to read or update.

## `map_filter(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_filter

Filters the entries of a `map` using a callback predicate.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `($K, $V) => bool`
  The map `key` to read or update. `K` is the key type of the input map. `V` is the value type of the input map.

## `map_from_arrays(keys, values)`
source: https://docs.chalk.ai/chalksql-docs#map_from_arrays

Creates a map from separate arrays of `keys` and `values`.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Overloads**

#### `map_from_arrays(keys, values)`

**Parameters**

- `keys`: `list<item: $K>`
  The map `keys` to read or update. `K` is the key type of the input map.
- `values`: `list<item: $V>`
  The input `values`. `V` is the value type of the input map.

#### `map_from_arrays(keys, values)`

**Parameters**

- `keys`: `large_list<item: $K>`
  The map `keys` to read or update. `K` is the key type of the input map.
- `values`: `large_list<item: $V>`
  The input `values`. `V` is the value type of the input map.

## `map_get(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_get

Retrieves a value from a `map` by `key`.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Overloads**

#### `map_get(map, key)`

Retrieves the value associated with a `key` from a `map`.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `$K`
  The map `key` to read or update. `K` is the key type of the input map.

#### `map_get(map, key)`

Retrieves the value associated with a string `key` from a `map` with automatic `key` type casting.

**Parameters**

- `map`: `map<string, $V>`
  The input `map`. `V` is the value type of the input map.
- `key`: `large_string`
  The map `key` to read or update.

## `map_key_exists(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_key_exists

Checks if a `map` contains any keys that match a given condition.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `$K`
  The map `key` to read or update. `K` is the key type of the input map.

## `map_keys(map)`
source: https://docs.chalk.ai/chalksql-docs#map_keys

Returns all keys from a `map` as a list.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.

## `map_keys_by_top_n_values(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_keys_by_top_n_values

Returns the keys of a `map` ordered by their top N highest values.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `int64`
  The map `key` to read or update.

## `map_subset(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_subset

Returns a subset of a `map` containing only the specified keys.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Overloads**

#### `map_subset(map, key)`

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `list<item: $K>`
  The map `key` to read or update. `K` is the key type of the input map.

#### `map_subset(map, key)`

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `large_list<item: $K>`
  The map `key` to read or update. `K` is the key type of the input map.

## `map_top_n(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_top_n

Returns the top N entries from a `map` ordered by value.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `int64`
  The map `key` to read or update.

## `map_top_n_keys(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_top_n_keys

Returns the top N keys from a `map` ordered by their values.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `int64`
  The map `key` to read or update.

## `map_top_n_values(map, key)`
source: https://docs.chalk.ai/chalksql-docs#map_top_n_values

Returns the top N values from a `map` ordered by value.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `int64`
  The map `key` to read or update.

## `map_values(map)`
source: https://docs.chalk.ai/chalksql-docs#map_values

Returns all values from a `map` as a list.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.

## `map_zip_with(map, key, function)`
source: https://docs.chalk.ai/chalksql-docs#map_zip_with

Merges two maps by applying a `function` to each matched `key` and pair of values.

**Type parameters.** `K` is the key type of the input map.

**Parameters**

- `map`: `map<$K, $V1>`
  The input `map`. `K` is the key type of the input map.
- `key`: `map<$K, $V2>`
  The map `key` to read or update. `K` is the key type of the input map.
- `function`: `($K, $V1, $V2) => $V3`
  The callback `function` applied to the elements. `K` is the key type of the input map.

## `no_keys_match(map, key)`
source: https://docs.chalk.ai/chalksql-docs#no_keys_match

Returns true if no keys in the `map` match the given predicate.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `($K) => bool`
  The map `key` to read or update. `K` is the key type of the input map.

## `no_values_match(map, key)`
source: https://docs.chalk.ai/chalksql-docs#no_values_match

Returns true if no values in the `map` match the given predicate.

**Type parameters.** `K` is the key type of the input map. `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K, $V>`
  The input `map`. `K` is the key type of the input map. `V` is the value type of the input map.
- `key`: `($V) => bool`
  The map `key` to read or update. `V` is the value type of the input map.

## `transform_keys(map, key)`
source: https://docs.chalk.ai/chalksql-docs#transform_keys

Returns a `map` with keys transformed by the given function.

**Type parameters.** `V` is the value type of the input map.

**Parameters**

- `map`: `map<$K1, $V>`
  The input `map`. `V` is the value type of the input map.
- `key`: `($K1, $V) => $K2`
  The map `key` to read or update. `V` is the value type of the input map.

## `transform_values(map, key)`
source: https://docs.chalk.ai/chalksql-docs#transform_values

Returns a `map` with values transformed by the given function.

**Type parameters.** `K` is the key type of the input map.

**Parameters**

- `map`: `map<$K, $V1>`
  The input `map`. `K` is the key type of the input map.
- `key`: `($K, $V1) => $V2`
  The map `key` to read or update. `K` is the key type of the input map.
