map function

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

Creates a map with the specified key-value pairs.

Syntax

map( [key1, value1] [, ...] )

Arguments

  • keyN: An expression of any comparable type. All keyN must share a least common type.
  • valueN: An expression of any type. All valueN must share a least common type.

Returns

A MAP with keys typed as the least common type of keyN and values typed as the least common type of valueN.

There can be 0 or more pairs.

If there is a duplicate key or a NULL key the function raises an error.

Examples

> SELECT map(1.0, '2', 3.0, '4');
 {1.0 -> 2, 3.0 -> 4}