From 64fd3fe35a9b0ffc5ddabc1ceb390c9052bc35bf Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Mon, 25 Dec 2017 23:53:57 +0300 Subject: [PATCH] added test for Dictionary(range_hashed) [#CLICKHOUSE-3521] --- .../configs/dictionaries/source.tsv | 8 +++--- .../generate_dictionaries.py | 27 ++++++++++++++++--- .../integration/test_dictionaries/test.py | 4 ++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/dbms/tests/integration/test_dictionaries/configs/dictionaries/source.tsv b/dbms/tests/integration/test_dictionaries/configs/dictionaries/source.tsv index d3fc6e1f3cc..438c619ab69 100644 --- a/dbms/tests/integration/test_dictionaries/configs/dictionaries/source.tsv +++ b/dbms/tests/integration/test_dictionaries/configs/dictionaries/source.tsv @@ -1,4 +1,4 @@ -0 0 0 0 50 13874 980694578 980694579 50 13874 980694578 980694579 0 0 4761183170873013810 2007-12-27 1970-01-02 06:51:14 0 -1 1 1 1 48 57392 4083802160 4083802161 48 -8144 -211165136 -211165135 1.5 1.5 10577349846663553072 2037-06-02 1970-01-02 09:50:24 0 -2 2 2 2 69 35909 1447922757 1447922758 69 -29627 1447922757 1447922758 3 3 18198135717204167749 1978-08-08 1970-01-02 03:52:21 1 -3 3 3 3 250 1274 1029309690 1029309691 -6 1274 1029309690 1029309691 4.5 4.5 9624464864560415994 1973-06-28 1970-01-02 03:21:14 2 +0 0 0 0 0000-00-00 0000-00-00 50 13874 980694578 980694579 50 13874 980694578 980694579 0 0 4761183170873013810 2007-12-27 1970-01-02 06:51:14 0 +1 1 1 1 1970-01-02 0000-00-00 48 57392 4083802160 4083802161 48 -8144 -211165136 -211165135 1.5 1.5 10577349846663553072 2037-06-02 1970-01-02 09:50:24 0 +2 2 2 2 0000-00-00 1970-01-02 69 35909 1447922757 1447922758 69 -29627 1447922757 1447922758 3 3 18198135717204167749 1978-08-08 1970-01-02 03:52:21 1 +3 3 3 3 1990-01-03 1990-01-03 250 1274 1029309690 1029309691 -6 1274 1029309690 1029309691 4.5 4.5 9624464864560415994 1973-06-28 1970-01-02 03:21:14 2 \ No newline at end of file diff --git a/dbms/tests/integration/test_dictionaries/generate_dictionaries.py b/dbms/tests/integration/test_dictionaries/generate_dictionaries.py index edae0bd451c..0a315a079ba 100644 --- a/dbms/tests/integration/test_dictionaries/generate_dictionaries.py +++ b/dbms/tests/integration/test_dictionaries/generate_dictionaries.py @@ -43,6 +43,9 @@ def generate_structure(): # Complex key dictionaries with (String, UInt8) key ['clickhouse_complex_mixed_key_hashed', 2, False], ['clickhouse_complex_mixed_key_cache', 2, False], + + # Range hashed dictionary + ['clickhouse_range_hashed', 3, False], ] @@ -102,6 +105,7 @@ def generate_dictionaries(path, structure): layout_cache = '128' layout_complex_key_hashed = '' layout_complex_key_cache = '128' + layout_range_hashed = '' key_simple = ''' @@ -135,7 +139,19 @@ def generate_dictionaries(path, structure): ''' - keys = [key_simple, key_complex_integers, key_complex_mixed] + key_range_hashed = ''' + + id + + + StartDate + + + EndDate + + ''' + + keys = [key_simple, key_complex_integers, key_complex_mixed, key_range_hashed] parent_attribute = ''' @@ -158,6 +174,9 @@ def generate_dictionaries(path, structure): # Complex key dictionaries with (String, UInt8) key [source_clickhouse, layout_complex_key_hashed], [source_clickhouse, layout_complex_key_cache], + + # Range hashed dictionary + [source_clickhouse, layout_range_hashed], ] file_names = [] @@ -176,6 +195,7 @@ def generate_dictionaries(path, structure): class DictionaryTestTable: def __init__(self, source_file_name): self.structure = '''id UInt64, key0 UInt8, key0_str String, key1 UInt8, + StartDate Date, EndDate Date, UInt8_ UInt8, UInt16_ UInt16, UInt32_ UInt32, UInt64_ UInt64, Int8_ Int8, Int16_ Int16, Int32_ Int32, Int64_ Int64, Float32_ Float32, Float64_ Float64, @@ -183,8 +203,8 @@ class DictionaryTestTable: Date_ Date, DateTime_ DateTime, Parent UInt64''' self.names_and_types = map(str.split, self.structure.split(',')) - self.keys_names_and_types = self.names_and_types[:4] - self.values_names_and_types = self.names_and_types[4:] + self.keys_names_and_types = self.names_and_types[:6] + self.values_names_and_types = self.names_and_types[6:] self.source_file_name = source_file_name self.rows = None @@ -213,6 +233,7 @@ class DictionaryTestTable: return '(' + ','.join(map(wrap_value, zip(row, types))) + ')' values = ','.join(map(make_tuple, lines)) + print query % (self.structure, values) instance.query(query % (self.structure, values)) def get_structure_for_keys(self, keys, enable_parent=True): diff --git a/dbms/tests/integration/test_dictionaries/test.py b/dbms/tests/integration/test_dictionaries/test.py index 96caf969606..b6eb7e33be8 100644 --- a/dbms/tests/integration/test_dictionaries/test.py +++ b/dbms/tests/integration/test_dictionaries/test.py @@ -45,10 +45,12 @@ def started_cluster(): ('clickhouse_flat', ('id',), True), ('clickhouse_complex_integers_key_hashed', ('key0', 'key1'), False), ('clickhouse_complex_mixed_key_hashed', ('key0_str', 'key1'), False), + ('clickhouse_range_hashed', ('id', 'StartDate', 'EndDate'), False), ], ids=['clickhouse_hashed', 'clickhouse_flat', 'clickhouse_complex_integers_key_hashed', - 'clickhouse_complex_mixed_key_hashed'] + 'clickhouse_complex_mixed_key_hashed', + 'clickhouse_range_hashed'] ) def dictionary_structure(started_cluster, request): return request.param