Skip to main content

Syntax

If you are using a dictionary with ClickHouse Cloud please use the DDL query option to create your dictionaries, and create your dictionary as user default. Also, verify the list of supported dictionary sources in the Cloud Compatibility guide.
A dictionary can be connected to ClickHouse from many different sources. The source is configured in the source section for configuration file and using the SOURCE clause for DDL statement.

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:

Column order of a custom query

The ClickHouse, MySQL, PostgreSQL and ODBC sources accept a query 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:
  1. the key column(s), in PRIMARY KEY order;
  2. for a range_hashed or complex_key_range_hashed dictionary, the range_min column, then the range_max column;
  3. the remaining attributes, in the order they are declared.
The ClickHouse source matches the result to that order by column name, so with it the order of the 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:
Last modified on August 10, 2026