map_zip_with function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Merges map1 and map2 into a single map.

Syntax

map_zip_with(map1, map2, func)

Arguments

  • map1: A MAP expression.
  • map2: A MAP expression of the same key type as map1
  • func: A lambda function taking three parameters. The first parameter is the key, followed by the values from each map.

Returns

A MAP where the key matches the key type of the input maps and the value is typed by the return type of the lambda function.

If a key is not matched by one side the respective value provided to the lambda function is NULL.

Examples

> SELECT map_zip_with(map(1, 'a', 2, 'b'), map(1, 'x', 2, 'y'), (k, v1, v2) -> concat(v1, v2));
 {1 -> ax, 2 -> by}