Syntax
A dictionary can be connected to ClickHouse from many different sources. The source is configured in thesource section for configuration file and using the SOURCE clause for DDL statement.
- DDL
- Configuration file
Supported dictionary sources
The following source types (SOURCE_TYPE/source_type) are available:
For source types Local file, Executable file, HTTP(s), ClickHouse
optional settings are available:
- DDL
- Configuration file
Column order of a custom query
The ClickHouse, MySQL, PostgreSQL and ODBC sources accept aquery field that
replaces the query ClickHouse would otherwise build from table and where.
A dictionary expects the columns of that result in a fixed order, which is not the order the
attributes are written in the CREATE DICTIONARY statement:
- the key column(s), in
PRIMARY KEYorder; - for a
range_hashedorcomplex_key_range_hasheddictionary, therange_mincolumn, then therange_maxcolumn; - the remaining attributes, in the order they are declared.
query does not matter as long as every column is named after the attribute it fills. The
MySQL, PostgreSQL and ODBC sources take the columns by position, so with those a query whose
columns are in any other order loads values into the wrong attributes. Depending on the types
involved, the dictionary either fails to load with a conversion error or stores wrong values, so
write the query in the order above: