Skip to main content
Scalar function
Returns NULL for a NULL input array or when an input entry struct is NULL. NULL keys are invalid; NULL values are allowed.

Syntax

Scalar

Arguments

Type notation used below:
  • K is the map key type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY, MAP or STRUCT.
  • V is the map value type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY, MAP or STRUCT.

Returns

  • Type: MAP<K,V>
  • Possible values: The constructed map.
  • NULL behavior: Returns NULL for a NULL input array or when an input entry struct is NULL. NULL keys are invalid; NULL values are allowed.
  • Shape: One key/value entry per distinct key.
  • Ordering: No sorted-map guarantee.

Properties

Usage notes

  • For last-wins duplicate handling, the retained entries appear in the original order of the surviving last occurrences, without key sorting.
  • If a key appears more than once, its last value is retained. This differs from MAP_FROM_ARRAYS in the Databricks context, which rejects duplicate keys.
  • INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

Examples

Typical behavior

Duplicate keys

Limitations

  • Each element must be a struct with exactly two fields. The first is the key and the second is the value, regardless of field names. NULL keys are rejected. Keys must support equality comparison and hashing.
Last modified on October 15, 2026