All Products
Search
Document Center

MaxCompute:MAP_ZIP_WITH

Last Updated:Sep 06, 2023

Merges Map input1 and Map input2 into a single map. The keys of the new map are the union of the keys of the two input maps. The value of each key of the new map is calculated by using func.

Syntax

<K, V1, V2, V3> map<K, V3> map_zip_with(map<K, V1> <input1>, map<K, V2> <input2>, function<K, V1, V2, V3> <func>)

Parameters

  • input1 and input2: required. These parameters specify maps. K and V in map<K, V> specify the keys and values of a map.

  • func: required. func consists of three input parameters, which correspond to a key, the value that corresponds to the key in input1, and the value that corresponds to the key in input2. If the key does not exist in input1 or input2, null is used to replace the value that corresponds to the key in func.

Return value

Data of the data type defined by func is returned.

Examples

-- The return value is {1:[1, 1, 4], 2:[2, 2, 5], 3:[3, null, null], 4:[4, null, 7]}. 
select map_zip_with(map(1, 1, 2, 2, 3, null), map(1, 4, 2, 5, 4, 7), (k, v1, v2) -> array(k, v1, v2));
Note

In this example, the combination of a hyphen and a closing angle bracket (->) is used. For more information about how to use the combination of a hyphen and a closing angle bracket (->) in Lambda functions, see Lambda functions.

Related functions

MAP_ZIP_WITH is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.