Внешний словарь Clickhouse не загружается

#database #clickhouse

#База данных #clickhouse

Вопрос:

Я создал словарь внешнего кэша, который я загружаю при запуске, установив для dictionaries_lazy_load значение False . Внешний словарь присутствует в system.dictionary следующим образом:

  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>
 

Ответ №1:

Словари XML существуют вне базы данных.

Словарь XML: ВЫБЕРИТЕ dictGet(‘cacheDictionary’

СОЗДАТЬ словарь: ВЫБЕРИТЕ dictGet(‘benchmark.cacheDictionary’

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

Внимание
параметр dict_name должен быть полностью указан для
словарей, созданных с помощью запросов DDL. Например. ..*

Комментарии:

1. Я по-прежнему получаю ту же ошибку, используя select dictGet(‘cacheDictionary’,’random1′,toUInt64(64)), даже после удаления интервала из <name> в xml.

2. Я имел в виду, что вам нужно удалить имя базы данных benchmark.

3. Я удалил тег <database> .

4. Хорошо, clickhouse просто вел себя странно, перезапустил виртуальную машину, и она заработала.