Clickhouse_Dictionary Key and Fields
字典键值配置说明
字典键、值的配置是在配置文件中的structure节点
整体的配置结构
| 1 | <dictionary> | 
Columns are described in the structure:
- <id>- key column.
- <attribute>- data column. 这里可以配置很多数据列
Key
Clickhouse 支持以下类型的Key:
- Numeric key. UInt64. 通过<id>来定义
- Composite key. 不同类型Key的set集合. 通过<key>来定义.
<id> 和 <key> 两者任选其一
Numeric Key
Format: UInt64.
配置举例:
| 1 | <id> | 
Composite Key
The key 可以是任意类型字段的tuple,存储类型 layout 的配置必须complex_key_hashed 或者 complex_key_cache.
提示:
Composite Key可以由单个元素组成。 例如,可以使用字符串作为主键。
The composite key 是在<key>节点中设置。 key字段的指定格式与字典属性相同。 例如:
| 1 | <structure> | 
对于dictGet*函数的查询,将传递tuple作为键。 示例:
| 1 | dictGetString('dict_name','attr_name',tuple('string for field1',num_for_field2)) | 
Attributes
配置:
| 1 | <structure> | 
配置字段:
- name – 列名。
- type – 列数据类型。参照数据源中的类型。 例如, MySQL, 在源table中字段可能是TEXT, VARCHAR, 或者BLOB类型,但是也是可以被更新为 String.
- null_value – 如果元素不存在,替换的默认值。
- expression – 该属性可以是表达式. The tag is not required.
- hierarchical – 支持阶级式(Hierarchical support). 镜像到父标识符. 默认为false。
- injective – (id->属性)是否是单射. 如果是, 则可以优化Group By 子句。默认false。
- is_object_id – 是否通过ObjectID对MongoDB文档执行查询.