ClickHouse/docs/zh/query_language/functions/ext_dict_functions.md

47 lines
1.7 KiB
Markdown
Raw Normal View History

# 字典函数 {#zi-dian-han-shu}
2019-05-05 17:38:05 +00:00
有关连接和配置外部词典的信息,请参阅[外部词典](../dicts/external_dicts.md)。
## dictGetUInt8, dictGetUInt16, dictGetUInt32, dictGetUInt64 {#dictgetuint8-dictgetuint16-dictgetuint32-dictgetuint64}
2019-05-05 17:38:05 +00:00
## dictGetInt8, dictGetInt16, dictGetInt32, dictGetInt64 {#dictgetint8-dictgetint16-dictgetint32-dictgetint64}
2019-05-05 17:38:05 +00:00
## dictGetFloat32, dictGetFloat64 {#dictgetfloat32-dictgetfloat64}
2019-05-05 17:38:05 +00:00
## dictGetDate, dictGetDateTime {#dictgetdate-dictgetdatetime}
2019-05-05 17:38:05 +00:00
## dictGetUUID {#dictgetuuid}
2019-05-05 17:38:05 +00:00
## dictGetString {#dictgetstring}
2019-05-05 17:38:05 +00:00
`dictGetT('dict_name', 'attr_name', id)`
- 使用id键获取dict\_name字典中attr\_name属性的值。`dict_name`和`attr_name`是常量字符串。`id`必须是UInt64。
如果字典中没有`id`键,则返回字典描述中指定的默认值。
2019-05-05 17:38:05 +00:00
## dictGetTOrDefault {#ext-dict-functions-dictgettordefault}
2019-05-05 17:38:05 +00:00
`dictGetTOrDefault('dict_name', 'attr_name', id, default)`
与`dictGetT`函数相同,但默认值取自函数的最后一个参数。
## dictIsIn {#dictisin}
2019-05-05 17:38:05 +00:00
`dictIsIn ('dict_name', child_id, ancestor_id)`
- 对于dict\_name分层字典查找child\_id键是否位于ancestor\_id或匹配ancestor\_id。返回UInt8。
2019-05-05 17:38:05 +00:00
## dictGetHierarchy {#dictgethierarchy}
2019-05-05 17:38:05 +00:00
`dictGetHierarchy('dict_name', id)`
- 对于dict\_name分层字典返回从id开始并沿父元素链继续的字典键数组。返回ArrayUInt64
2019-05-05 17:38:05 +00:00
## dictHas {#dicthas}
2019-05-05 17:38:05 +00:00
`dictHas('dict_name', id)`
- 检查字典是否存在指定的`id`。如果不存在则返回0;如果存在则返回1。
2019-05-05 17:38:05 +00:00
2020-01-30 10:34:55 +00:00
[来源文章](https://clickhouse.tech/docs/en/query_language/functions/ext_dict_functions/) <!--hide-->