map_contains_key function (Databricks SQL)

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