Dictionary attributes

For a query to the `dictGet*` function, a tuple is passed as the key. Example: `dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2))`.

## Attributes[​](#attributes "Direct link to Attributes")

Configuration example:

```
<structure>
    ...
    <attribute>
        <name>Name</name>
        <type>ClickHouseDataType</type>
        <null_value></null_value>
        <expression>rand64()</expression>
        <hierarchical>true</hierarchical>
        <injective>true</injective>
        <is_object_id>true</is_object_id>
    </attribute>
</structure>
```

or

```
CREATE DICTIONARY somename (
    Name ClickHouseDataType DEFAULT '' EXPRESSION rand64() HIERARCHICAL INJECTIVE IS_OBJECT_ID
)
```

Configuration fields:

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Tag Description Required|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `name` Column name. Yes|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `type` ClickHouse data type: [UInt8](/docs/sql-reference/data-types/int-uint), [UInt16](/docs/sql-reference/data-types/int-uint), [UInt32](/docs/sql-reference/data-types/int-uint), [UInt64](/docs/sql-reference/data-types/int-uint), [Int8](/docs/sql-reference/data-types/int-uint), [Int16](/docs/sql-reference/data-types/int-uint), [Int32](/docs/sql-reference/data-types/int-uint), [Int64](/docs/sql-reference/data-types/int-uint), [Float32](/docs/sql-reference/data-types/float), [Float64](/docs/sql-reference/data-types/float), [UUID](/docs/sql-reference/data-types/uuid), [Decimal32](/docs/sql-reference/data-types/decimal), [Decimal64](/docs/sql-reference/data-types/decimal), [Decimal128](/docs/sql-reference/data-types/decimal), [Decimal256](/docs/sql-reference/data-types/decimal),[Date](/docs/sql-reference/data-types/date), [Date32](/docs/sql-reference/data-types/date32), [DateTime](/docs/sql-reference/data-types/datetime), [DateTime64](/docs/sql-reference/data-types/datetime64), [String](/docs/sql-reference/data-types/string), [Array](/docs/sql-reference/data-types/array). ClickHouse tries to cast value from dictionary to the specified data type. For example, for MySQL, the field might be `TEXT`, `VARCHAR`, or `BLOB` in the MySQL source table, but it can be uploaded as `String` in ClickHouse. [Nullable](/docs/sql-reference/data-types/nullable) is currently supported for [Flat](/docs/sql-reference/statements/create/dictionary/layouts/flat), [Hashed](/docs/sql-reference/statements/create/dictionary/layouts/hashed), [ComplexKeyHashed](/docs/sql-reference/statements/create/dictionary/layouts/hashed#complex_key_hashed), [Direct](/docs/sql-reference/statements/create/dictionary/layouts/direct), [ComplexKeyDirect](/docs/sql-reference/statements/create/dictionary/layouts/direct#complex_key_direct), [RangeHashed](/docs/sql-reference/statements/create/dictionary/layouts/range-hashed), Polygon, [Cache](/docs/sql-reference/statements/create/dictionary/layouts/cache), [ComplexKeyCache](/docs/sql-reference/statements/create/dictionary/layouts/cache), [SSDCache](/docs/sql-reference/statements/create/dictionary/layouts/ssd-cache), [SSDComplexKeyCache](/docs/sql-reference/statements/create/dictionary/layouts/ssd-cache#complex_key_ssd_cache) dictionaries. In [IPTrie](/docs/sql-reference/statements/create/dictionary/layouts/ip-trie) dictionaries `Nullable` types are not supported. Yes|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `null_value` Default value for a non-existing element. In the example, it is an empty string. [NULL](/docs/sql-reference/syntax#null) value can be used only for the `Nullable` types (see the previous line with types description). Yes|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `expression` [Expression](/docs/sql-reference/syntax#expressions) that ClickHouse executes on the value. The expression can be a column name in the remote SQL database. Thus, you can use it to create an alias for the remote column.  Default value: no expression. No|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `hierarchical` If `true`, the attribute contains the value of a parent key for the current key. See [Hierarchical Dictionaries](/docs/sql-reference/statements/create/dictionary/layouts/hierarchical).  Default value: `false`. No|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `injective` Flag that shows whether the `id -> attribute` image is [injective](https://en.wikipedia.org/wiki/Injective_function). If `true`, ClickHouse can automatically place after the `GROUP BY` clause the requests to dictionaries with injection. Usually it significantly reduces the amount of such requests.  Default value: `false`. No|  |  |  | | --- | --- | --- | | `is_object_id` Flag that shows whether the query is executed for a MongoDB document by `ObjectID`.  Default value: `false`.  | | | | | | | | | | | | | | | | | | | | | | | |

- [Key](#key)
  - [Numeric Key](#numeric-key)- [Composite Key](#composite-key)- [Attributes](#attributes)

Was this page helpful?