Clickhouse 外部词典未加载
Clickhouse External Dictionary not loading
我创建了一个外部缓存字典,我通过将 dictionaries_lazy_load 设置为 False 来加载它。外部字典在 system.dictionaries 中存在,如下所示:
database ──┬─name─────────────┬─────────────────────────────────uuid─┬─status─┬─origin──────────────────────────────────────────┬─type──┬─key────┬─attribute.names────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─attribute.types───────────────────────────────────────────────────────────────────────────────────────────────────────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬─load_factor─┬─source──────────────────────────────────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┬─last_successful_update_time─┬─loading_duration─┬─last_exception─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ benchmark │ cacheDictionary │ 00000000-0000-0000-0000-000000000000 │ LOADED │ /etc/clickhouse-server/benchmark_dictionary.xml │ Cache │ UInt64 │ ['date','integers','filterColumn','ramdom0','ramdom1','ramdom2','ramdom3','ramdom4','ramdom5','ramdom6','ramdom7','ramdom8','ramdom9'] │ ['Date','UInt64','Float64','String','String','String','String','String','String','String','String','String','String'] │ 26481680 │ 0 │ nan │ 0 │ 0 │ Executable: cat /var/lib/clickhouse/user_files/test.csv │ 0 │ 0 │ 2021-01-12 20:50:36 │ 2021-01-12 20:50:36 │ 0.009 │
但是当我 运行 查询 SELECT dictGet('benchmark.cacheDictionary', 'random1', toUInt64(64)),
我收到错误
Received exception from server (version 20.8.3): Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: external dictionary 'benchmark.cacheDictionary' not found.
有什么想法吗?我在下面添加了 xml 代码。
<yandex>
<dictionary>
<name>cacheDictionary </name>
<database>benchmark</database>
<source>
<executable>
<command>cat /var/lib/clickhouse/user_files/test.csv</command>
<format>CSV</format>
</executable>
</source>
<layout>
<cache>
<size_in_cells>130000</size_in_cells>
</cache>
</layout>
<lifetime>0</lifetime>
<structure>
<id>
<name>referentialKey</name>
</id>
<attribute>
<name>date</name>
<type>Date</type>
<null_value></null_value>
</attribute>
<attribute>
<name>integers</name>
<type>UInt64</type>
<null_value></null_value>
</attribute>
<attribute>
<name>filterColumn</name>
<type>Float64</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom0</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom1</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom2</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom3</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom4</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom5</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom6</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom7</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom8</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom9</name>
<type>String</type>
<null_value></null_value>
</attribute>
</structure>
</dictionary>
</yandex>
XML 词典不在数据库中。
XML 字典:SELECT dictGet('cacheDictionary'
创建字典:SELECT dictGet('benchmark.cacheDictionary'
https://clickhouse.tech/docs/en/sql-reference/functions/ext-dict-functions/#dictget
Attention
dict_name parameter must be fully qualified for
dictionaries created with DDL queries. Eg. ..*
我创建了一个外部缓存字典,我通过将 dictionaries_lazy_load 设置为 False 来加载它。外部字典在 system.dictionaries 中存在,如下所示:
database ──┬─name─────────────┬─────────────────────────────────uuid─┬─status─┬─origin──────────────────────────────────────────┬─type──┬─key────┬─attribute.names────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─attribute.types───────────────────────────────────────────────────────────────────────────────────────────────────────┬─bytes_allocated─┬─query_count─┬─hit_rate─┬─element_count─┬─load_factor─┬─source──────────────────────────────────────────────────┬─lifetime_min─┬─lifetime_max─┬──loading_start_time─┬─last_successful_update_time─┬─loading_duration─┬─last_exception─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ benchmark │ cacheDictionary │ 00000000-0000-0000-0000-000000000000 │ LOADED │ /etc/clickhouse-server/benchmark_dictionary.xml │ Cache │ UInt64 │ ['date','integers','filterColumn','ramdom0','ramdom1','ramdom2','ramdom3','ramdom4','ramdom5','ramdom6','ramdom7','ramdom8','ramdom9'] │ ['Date','UInt64','Float64','String','String','String','String','String','String','String','String','String','String'] │ 26481680 │ 0 │ nan │ 0 │ 0 │ Executable: cat /var/lib/clickhouse/user_files/test.csv │ 0 │ 0 │ 2021-01-12 20:50:36 │ 2021-01-12 20:50:36 │ 0.009 │
但是当我 运行 查询 SELECT dictGet('benchmark.cacheDictionary', 'random1', toUInt64(64)), 我收到错误
Received exception from server (version 20.8.3): Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: external dictionary 'benchmark.cacheDictionary' not found.
有什么想法吗?我在下面添加了 xml 代码。
<yandex>
<dictionary>
<name>cacheDictionary </name>
<database>benchmark</database>
<source>
<executable>
<command>cat /var/lib/clickhouse/user_files/test.csv</command>
<format>CSV</format>
</executable>
</source>
<layout>
<cache>
<size_in_cells>130000</size_in_cells>
</cache>
</layout>
<lifetime>0</lifetime>
<structure>
<id>
<name>referentialKey</name>
</id>
<attribute>
<name>date</name>
<type>Date</type>
<null_value></null_value>
</attribute>
<attribute>
<name>integers</name>
<type>UInt64</type>
<null_value></null_value>
</attribute>
<attribute>
<name>filterColumn</name>
<type>Float64</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom0</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom1</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom2</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom3</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom4</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom5</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom6</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom7</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom8</name>
<type>String</type>
<null_value></null_value>
</attribute>
<attribute>
<name>ramdom9</name>
<type>String</type>
<null_value></null_value>
</attribute>
</structure>
</dictionary>
</yandex>
XML 词典不在数据库中。
XML 字典:SELECT dictGet('cacheDictionary'
创建字典:SELECT dictGet('benchmark.cacheDictionary'
https://clickhouse.tech/docs/en/sql-reference/functions/ext-dict-functions/#dictget
Attention dict_name parameter must be fully qualified for dictionaries created with DDL queries. Eg. ..*