All Products
Search
Document Center

MaxCompute:MAP_ENTRIES

Last Updated:Mar 26, 2026

Converts key-value pairs in a map into a struct array.

Syntax

array<struct<K, V>> map_entries(map<K, V> <a>)

Parameters

ParameterRequiredDescription
aYesA map. K and V specify the key and value types of the map.

Return value

Returns array<struct<K, V>>. Each struct contains two fields: key (type K) and value (type V). If a is null, null is returned.

Example

-- Returns [{key:1, value:a}, {key:2, value:b}].
SELECT map_entries(map(1, 'a', 2, 'b'));

Related functions

MAP_ENTRIES is a complex type function. For other functions that process ARRAY, MAP, STRUCT, and JSON data, see Complex type functions.