MAP_CONTAINS_KEY
Description
Determines whether the given map
contains a specific key key
Syntax
MAP_CONTAINS_KEY(<map>, <key>)
Parameters
Parameter | Description |
---|---|
<map> | Input map content |
<key> | The key to be retrieved |
Return Value
Determines whether the given map
contains a specific key key
, and returns 1 if it exists, otherwise returns 0.
Example
select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11);
+-----------------------------------------------+-----------------------------------------------+
| map_contains_key(map(null, 1, 2, null), null) | map_contains_key(map(1, "100", 0.1, 2), 0.11) |
+-----------------------------------------------+-----------------------------------------------+
| 1 | 0 |
+-----------------------------------------------+-----------------------------------------------+
- Key comparison in maps uses "null-safe equal" (null and null are considered equal), which differs from the standard SQL definition.
select map_contains_key(map(null,1), null);
+-------------------------------------+
| map_contains_key(map(null,1), null) |
+-------------------------------------+
| 1 |
+-------------------------------------+