All Products
Search
Document Center

MaxCompute:MULTIMAP_FROM_ENTRIES

Last Updated:Sep 21, 2026

Returns a map created from an array of structs, where each key is associated with an array of its corresponding values.

Command format

	multimap_from_entries(array<struct<K, V>>)

Parameters

array<struct<K, V>>: An array of key-value structs.

Return value

Returns a map of the format map<K, array<V>>.

  • In the returned map, each key is associated with an array that contains all of its corresponding values.

  • If the input array is null, null is returned.

  • An exception is thrown if a struct in the array does not have exactly two fields or if a key is null.

Example

SELECT multimap_from_entries(array(struct(1, 'a'), 
                                     struct(2, 'b'), 
                                     struct(1, 'c')));

The following result is returned:

{1 : ['a', 'c'],  2: ['b']}

Related functions

The MULTIMAP_FROM_ENTRIES function is a complex type function. For more functions that process complex data types, such as ARRAY, MAP, STRUCT, and JSON data, see Complex type functions.