【问题标题】:Clickhouse External Dictionary not loadingClickhouse 外部词典未加载
【发布时间】:2021-01-12 21:01:56
【问题描述】:

我创建了一个外部缓存字典,我通过将 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>

【问题讨论】:

    标签: database clickhouse


    【解决方案1】:

    XML 字典存在于数据库之外。

    XML 字典:SELECT dictGet('cacheDictionary'

    创建字典:SELECT dictGet('benchmark.cacheDictionary'

    https://clickhouse.tech/docs/en/sql-reference/functions/ext-dict-functions/#dictget

    注意
    dict_name 参数必须完全限定为
     使用 DDL 查询创建的字典。例如。 ..*
    

    【讨论】:

    • 我使用 select dictGet('cacheDictionary','random1',toUInt64(64)) 仍然得到同样的错误,即使在 xml 中从 中删除了空格。
    • 我的意思是你需要删除数据库名称benchmark.
    • 我删除了 标签。
    • 好吧,clickhouse 只是表现得很奇怪,重新启动了虚拟机,它就可以工作了。
    猜你喜欢
    • 2021-09-24
    • 2017-09-25
    • 1970-01-01
    • 2020-07-14
    • 1970-01-01
    • 1970-01-01
    • 2018-12-27
    • 2014-02-13
    • 2013-05-30
    相关资源
    最近更新 更多