2022-05-23 12:43:13 +00:00
|
|
|
<test>
|
|
|
|
<substitutions>
|
|
|
|
<substitution>
|
|
|
|
<name>dictionary_layout</name>
|
|
|
|
<values>
|
|
|
|
<value>hashed</value>
|
|
|
|
<value>hashed_array</value>
|
|
|
|
</values>
|
|
|
|
</substitution>
|
|
|
|
|
|
|
|
<substitution>
|
|
|
|
<name>func</name>
|
|
|
|
<values>
|
|
|
|
<value>dictGetHierarchy</value>
|
|
|
|
<value>dictGetDescendants</value>
|
|
|
|
</values>
|
|
|
|
</substitution>
|
|
|
|
</substitutions>
|
|
|
|
|
|
|
|
<create_query>
|
|
|
|
CREATE TABLE hierarchical_dictionary_source_table
|
|
|
|
(
|
|
|
|
id UInt64,
|
|
|
|
parent_id UInt64
|
2022-06-09 13:29:27 +00:00
|
|
|
) ENGINE = MergeTree ORDER BY id;
|
2022-05-23 12:43:13 +00:00
|
|
|
</create_query>
|
|
|
|
|
|
|
|
<create_query>
|
|
|
|
CREATE DICTIONARY hierarchical_{dictionary_layout}_dictionary
|
|
|
|
(
|
|
|
|
id UInt64,
|
2022-06-13 11:31:02 +00:00
|
|
|
parent_id UInt64 HIERARCHICAL
|
2022-05-23 12:43:13 +00:00
|
|
|
)
|
|
|
|
PRIMARY KEY id
|
|
|
|
SOURCE(CLICKHOUSE(DB 'default' TABLE 'hierarchical_dictionary_source_table'))
|
2022-06-09 13:29:27 +00:00
|
|
|
LAYOUT({dictionary_layout})
|
|
|
|
LIFETIME(0);
|
|
|
|
</create_query>
|
|
|
|
|
|
|
|
<create_query>
|
|
|
|
CREATE DICTIONARY hierarchical_flat_dictionary
|
|
|
|
(
|
|
|
|
id UInt64,
|
2022-06-13 11:31:02 +00:00
|
|
|
parent_id UInt64 HIERARCHICAL
|
2022-06-09 13:29:27 +00:00
|
|
|
)
|
|
|
|
PRIMARY KEY id
|
|
|
|
SOURCE(CLICKHOUSE(DB 'default' TABLE 'hierarchical_dictionary_source_table'))
|
|
|
|
LAYOUT(FLAT(max_array_size 1000001))
|
2022-05-23 12:43:13 +00:00
|
|
|
LIFETIME(0);
|
|
|
|
</create_query>
|
|
|
|
|
|
|
|
<fill_query>
|
|
|
|
INSERT INTO hierarchical_dictionary_source_table
|
2022-06-09 13:29:27 +00:00
|
|
|
WITH 5000 AS first_level_start, 50000 as second_level_start
|
|
|
|
SELECT
|
|
|
|
(number + 1) as id,
|
|
|
|
multiIf(id > second_level_start, id % (second_level_start - first_level_start) + first_level_start + 1,
|
|
|
|
id > first_level_start, (id % first_level_start) + 1,
|
|
|
|
0) as parent_id
|
2022-05-23 12:43:13 +00:00
|
|
|
FROM system.numbers
|
2022-06-09 13:29:27 +00:00
|
|
|
LIMIT 1000000;
|
2022-05-23 12:43:13 +00:00
|
|
|
</fill_query>
|
|
|
|
|
|
|
|
<query>
|
2022-06-09 13:29:27 +00:00
|
|
|
SELECT {func}('hierarchical_flat_dictionary', number + 1) FROM numbers(1000000) FORMAT Null;
|
|
|
|
</query>
|
|
|
|
<query>
|
|
|
|
SELECT {func}('hierarchical_{dictionary_layout}_dictionary', number + 1) FROM numbers(1000000) FORMAT Null;
|
2022-05-23 12:43:13 +00:00
|
|
|
</query>
|
|
|
|
|
|
|
|
<drop_query>DROP DICTIONARY IF EXISTS hierarchical_{dictionary_layout}_dictionary;</drop_query>
|
2022-06-09 13:29:27 +00:00
|
|
|
<drop_query>DROP DICTIONARY IF EXISTS hierarchical_flat_dictionary;</drop_query>
|
2022-12-16 14:12:52 +00:00
|
|
|
<drop_query>DROP TABLE IF EXISTS hierarchical_dictionary_source_table;</drop_query>
|
2022-05-23 12:43:13 +00:00
|
|
|
</test>
|