This commit is contained in:
Alexey Milovidov 2020-04-20 08:29:08 +03:00
parent 3862085af7
commit 38aaa6206e

View File

@ -1,10 +1,10 @@
DROP TABLE IF EXISTS dict_source;
CREATE TABLE dict_source (id UInt64, parent_id UInt64, value String) ENGINE = Memory;
INSERT INTO dict_source VALUES (1, 0, 'hello'), (2, 1, 'world'), (3, 2, 'upyachka'), (11, 22, 'a'), (22, 11, 'b');
DROP DATABASE IF EXISTS database_for_dict;
CREATE DATABASE database_for_dict Engine = Ordinary;
DROP TABLE IF EXISTS database_for_dict.dict_source;
CREATE TABLE database_for_dict.dict_source (id UInt64, parent_id UInt64, value String) ENGINE = Memory;
INSERT INTO database_for_dict.dict_source VALUES (1, 0, 'hello'), (2, 1, 'world'), (3, 2, 'upyachka'), (11, 22, 'a'), (22, 11, 'b');
DROP DICTIONARY IF EXISTS database_for_dict.dictionary_with_hierarchy;
CREATE DICTIONARY database_for_dict.dictionary_with_hierarchy
@ -12,7 +12,7 @@ CREATE DICTIONARY database_for_dict.dictionary_with_hierarchy
id UInt64, parent_id UInt64 HIERARCHICAL, value String
)
PRIMARY KEY id
SOURCE(CLICKHOUSE(host 'localhost' port 9000 user 'default' table 'dict_source'))
SOURCE(CLICKHOUSE(host 'localhost' port 9000 user 'default' db 'database_for_dict' table 'dict_source'))
LAYOUT(HASHED())
LIFETIME(MIN 1 MAX 1);
@ -41,7 +41,7 @@ CREATE DICTIONARY database_for_dict.dictionary_with_hierarchy
id UInt64, parent_id UInt64 HIERARCHICAL, value String
)
PRIMARY KEY id
SOURCE(CLICKHOUSE(host 'localhost' port 9000 user 'default' table 'dict_source'))
SOURCE(CLICKHOUSE(host 'localhost' port 9000 user 'default' db 'database_for_dict' table 'dict_source'))
LAYOUT(FLAT())
LIFETIME(MIN 1 MAX 1);
@ -70,7 +70,7 @@ CREATE DICTIONARY database_for_dict.dictionary_with_hierarchy
id UInt64, parent_id UInt64 HIERARCHICAL, value String
)
PRIMARY KEY id
SOURCE(CLICKHOUSE(host 'localhost' port 9000 user 'default' table 'dict_source'))
SOURCE(CLICKHOUSE(host 'localhost' port 9000 user 'default' db 'database_for_dict' table 'dict_source'))
LAYOUT(CACHE(SIZE_IN_CELLS 10))
LIFETIME(MIN 1 MAX 1);
@ -93,5 +93,5 @@ SELECT dictGetHierarchy('database_for_dict.dictionary_with_hierarchy', materiali
DROP DICTIONARY database_for_dict.dictionary_with_hierarchy;
DROP TABLE dict_source;
DROP TABLE database_for_dict.dict_source;
DROP DATABASE database_for_dict;