Back to Clickhouse

Dictionary Sources

docs/en/sql-reference/statements/create/dictionary/sources/overview.md

26.4.1.1-new2.2 KB
Original Source

import CloudDetails from '@site/docs/sql-reference/statements/create/dictionary/_snippet_dictionary_in_cloud.md'; import CloudNotSupportedBadge from '@theme/badges/CloudNotSupportedBadge'; import ExperimentalBadge from '@theme/badges/ExperimentalBadge'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Syntax {#dictionary-sources}

<CloudDetails />

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.

<Tabs> <TabItem value="ddl" label="DDL" default>
sql
CREATE DICTIONARY dict_name (...)
...
SOURCE(SOURCE_TYPE(param1 val1 ... paramN valN)) -- Source configuration
...
</TabItem> <TabItem value="xml" label="Configuration file">
xml
<clickhouse>
  <dictionary>
    ...
    <source>
      <source_type>
        <!-- Source configuration -->
      </source_type>
    </source>
    ...
  </dictionary>
  ...
</clickhouse>
</TabItem> </Tabs>

Supported dictionary sources {#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:

<Tabs> <TabItem value="ddl" label="DDL" default>
sql
SOURCE(FILE(path './user_files/os.tsv' format 'TabSeparated'))
--highlight-next-line
SETTINGS(format_csv_allow_single_quotes = 0)
</TabItem> <TabItem value="xml" label="Configuration file">
xml
<source>
  <file>
    <path>/opt/dictionaries/os.tsv</path>
    <format>TabSeparated</format>
  </file>
  <settings>
#highlight-next-line
      <format_csv_allow_single_quotes>0</format_csv_allow_single_quotes>
  </settings>
</source>
</TabItem> </Tabs>