structure clause describes the dictionary key and fields available for queries.
XML description:
<id>— Key column<attribute>— Data column: there can be a multiple number of attributes.
PRIMARY KEY— Key columnAttrName AttrType— Data column. There can be a multiple number of attributes.
Key
ClickHouse supports the following types of keys:- Numeric key.
UInt64. Defined in the<id>tag or usingPRIMARY KEYkeyword. - Composite key. Set of values of different types. Defined in the tag
<key>orPRIMARY KEYkeyword.
<id> or <key>. DDL-query must contain single PRIMARY KEY.
You must not describe key as an attribute.
Numeric Key
Type:UInt64.
Configuration example:
name– The name of the column with keys.
PRIMARY KEY– The name of the column with keys.
Composite Key
The key can be atuple from any types of fields. The layout in this case must be complex_key_hashed or complex_key_cache.
The key structure is set in the element <key>. Key fields are specified in the same format as the dictionary attributes. Example:
dictGet* function, a tuple is passed as the key. Example: dictGetString('dict_name', 'attr_name', tuple('string for field1', num_for_field2)).