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

# MAP_ENTRIES

> Returns map entries as an array of key/value structs.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL for a NULL map. NULL values are retained inside non-NULL entry structs.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
map_entries(map)
```

## Arguments

Type notation used below:

* K is the map key type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY, MAP or STRUCT.
* V is the map value type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY, MAP or STRUCT.

| Name | Type | Required | Description |
| - | - | - | - |
| map | MAP\<K,V> | Yes | The map to inspect. A lookup key must have the map's key type after conversion. Map keys must be non-NULL. Nested values retain their declared element/field types. |

## Returns

* Type: ARRAY\<STRUCT\<key: K, value: V>>
* Possible values: One key/value struct per entry.
* NULL behavior: Returns NULL for a NULL map. NULL values are retained inside non-NULL entry structs.
* Shape: Each array element has fields key and value; key is non-NULL and value follows map value nullability.
* Ordering: Underlying map entry order; no sorting is performed.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
* For ARRAY-valued keys or values, construct the input map with MAP\_FROM\_ARRAYS. The ordinary two-argument MAP constructor can interpret ARRAY arguments as parallel key/value lists.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT map_entries(map_from_arrays(ARRAY['a'], ARRAY[1])) AS entries;
```

| entries |
| - |
| \[\{"key":"a","value":1}] |

### An entry with a NULL value

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT map_entries(map('a', CAST(NULL AS INT))) AS entries;
```

| entries |
| - |
| \[\{"key":"a","value":null}] |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.