Skip to content

Instantly share code, notes, and snippets.

@filimonov
Created August 31, 2018 09:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save filimonov/cbafa8ca85268693b7bf28c14473ab34 to your computer and use it in GitHub Desktop.
Save filimonov/cbafa8ca85268693b7bf28c14473ab34 to your computer and use it in GitHub Desktop.
ClickHouse dictionaries with connection credentials substituted from another file
<?xml version="1.0"?>
<yandex>
<mysql_config>
<port>3306</port>
<user>user</user>
<password>123</password>
<replica>
<host>mysql_host</host>
<priority>1</priority>
</replica>
<db>owa_config</db>
</mysql_config>
</yandex>
<?xml version="1.0"?>
<yandex>
<include_from>/etc/clickhouse-server/dict_sources.xml</include_from>
<comment>....</comment>
<dictionary>
<name>customer</name>
<source>
<mysql incl="mysql_config">
<table>customer</table>
<invalidate_query>select concat(max(audit),count(*)) from customer</invalidate_query>
</mysql>
</source>
<lifetime>
<!-- every 8-12 h dict will be fully reloaded even if invalidate_query result doesn't change -->
<min>10800</min>
<max>43200</max>
</lifetime>
<layout>
<flat />
</layout>
<structure>
<id>
<name>customerid</name>
</id>
<!-- usage: SELECT dictGetString('customer', 'company', toUInt64(505)) -->
<attribute>
<name>company</name>
<type>String</type>
<null_value></null_value>
</attribute>
<!-- usage: SELECT dictGetString('customer', 'email', toUInt64(505)) -->
<attribute>
<name>email</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>status</name>
<type>String</type>
<null_value></null_value>
</attribute>
</structure>
</dictionary>
</yandex>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment