- 类别:
半结构化和结构化数据函数 (映射)
MAP_CONTAINS_KEY¶
确定指定的 MAP 是否包含指定的键。
语法¶
实参¶
key要查找的键。
map要搜索的映射。
返回¶
如果指定的映射包含指定的键,则返回 TRUE。
如果指定的映射不包含指定的键,则返回 FALSE。
使用说明¶
键表达式的类型必须与映射的键的类型匹配。如果类型为 VARCHAR,则类型可以是不同的长度。
对于 NULL 输入,输出为 NULL。
示例¶
该函数搜索 k1 键,并在映射中找到该键:
该函数搜索 k1 键,但在映射中找不到该键:
SELECT 语句传入的键使用的类型与映射中的键不同:
Create a temporary table that contains MAP values:
查询表以显示数据:
Determine whether the map in the attrs column contains the key in the ins_key column:
The output shows the following:
The map in the
attrscolumn in row1doesn't contain the key (material) in theins_keycolumn.The map in the
attrscolumn in row2contains the key (brand) in theins_keycolumn.