map_contains_key function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 10.3 and above

Returns true if map contains key.

Syntax

map_contains_key(map, key)

Arguments

  • map: An map to be searched.

  • key: An expression with a type sharing a least common type with the map keys.

Returns

A BOOLEAN. If map or key is NULL, the result is NULL.

Examples

> SELECT map_contains_key(map(1, 'a', 2, 'b'), 2);
 true

> SELECT map_contains_key(map(1, 'a', 2, 'b'), 3);
 false

> SELECT map_contains_key(map(1, 'a', 2, 'b'), NULL);
 NULL