From f9879ae41b31305ffc1a89b7ed8004101255db79 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 27 Apr 2016 08:23:55 +0300 Subject: [PATCH] Added test [#METR-20856]. --- .../00327_summing_composite_nested.reference | 87 +++++++++++++++++++ .../00327_summing_composite_nested.sql | 37 ++++++++ 2 files changed, 124 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00327_summing_composite_nested.reference create mode 100644 dbms/tests/queries/0_stateless/00327_summing_composite_nested.sql diff --git a/dbms/tests/queries/0_stateless/00327_summing_composite_nested.reference b/dbms/tests/queries/0_stateless/00327_summing_composite_nested.reference new file mode 100644 index 00000000000..93ed05ad21e --- /dev/null +++ b/dbms/tests/queries/0_stateless/00327_summing_composite_nested.reference @@ -0,0 +1,87 @@ +2000-01-01 1 [1,2] [3,4] [10,11] [0,1,2] [3,4,5] [-1,-2,-3] [1,10,100] +2000-01-01 1 [2,1] [4,3] [20,22] [2,2,1] [5,5,0] [-3,-3,-33] [10,100,1000] +2000-01-01 2 [1,2] [3,4] [10,11] [0,1,2] [3,4,5] [-1,-2,-3] [1,10,100] +2000-01-01 2 [2,1,1] [4,3,3] [20,22,33] [2,2] [5,5] [-3,-3] [10,100] +2000-01-01 2 [1,2] [3,4] [10,11] [0,1,2] [3,4,5] [-1,-2,-3] [1,10,100] +2000-01-01 1 1 3 10 +2000-01-01 1 1 3 22 +2000-01-01 1 2 4 11 +2000-01-01 1 2 4 20 +2000-01-01 2 1 3 10 +2000-01-01 2 1 3 10 +2000-01-01 2 1 3 22 +2000-01-01 2 1 3 33 +2000-01-01 2 2 4 11 +2000-01-01 2 2 4 11 +2000-01-01 2 2 4 20 +2000-01-01 1 1 3 32 +2000-01-01 1 2 4 31 +2000-01-01 2 1 3 75 +2000-01-01 2 2 4 42 +2000-01-01 1 1 3 32 +2000-01-01 1 2 4 31 +2000-01-01 2 1 3 75 +2000-01-01 2 2 4 42 +2000-01-01 1 0 3 -1 1 +2000-01-01 1 1 0 -33 1000 +2000-01-01 1 1 4 -2 10 +2000-01-01 1 2 5 -3 10 +2000-01-01 1 2 5 -3 100 +2000-01-01 1 2 5 -3 100 +2000-01-01 2 0 3 -1 1 +2000-01-01 2 0 3 -1 1 +2000-01-01 2 1 4 -2 10 +2000-01-01 2 1 4 -2 10 +2000-01-01 2 2 5 -3 10 +2000-01-01 2 2 5 -3 100 +2000-01-01 2 2 5 -3 100 +2000-01-01 2 2 5 -3 100 +2000-01-01 1 0 3 -1 1 +2000-01-01 1 1 0 -33 1000 +2000-01-01 1 1 4 -2 10 +2000-01-01 1 2 5 -3 210 +2000-01-01 2 0 3 -1 2 +2000-01-01 2 1 4 -2 20 +2000-01-01 2 2 5 -3 310 +2000-01-01 1 0 3 -1 1 +2000-01-01 1 1 0 -33 1000 +2000-01-01 1 1 4 -2 10 +2000-01-01 1 2 5 -3 210 +2000-01-01 2 0 3 -1 2 +2000-01-01 2 1 4 -2 20 +2000-01-01 2 2 5 -3 310 +2000-01-01 1 [1,2] [3,4] [32,31] [0,1,1,2] [3,0,4,5] [-1,-33,-2,-3] [1,1000,10,210] +2000-01-01 2 [1,2] [3,4] [75,42] [0,1,2] [3,4,5] [-1,-2,-3] [2,20,310] +2000-01-01 1 1 3 32 +2000-01-01 1 2 4 31 +2000-01-01 2 1 3 75 +2000-01-01 2 2 4 42 +2000-01-01 1 1 3 32 +2000-01-01 1 2 4 31 +2000-01-01 2 1 3 75 +2000-01-01 2 2 4 42 +2000-01-01 1 1 3 32 +2000-01-01 1 2 4 31 +2000-01-01 2 1 3 75 +2000-01-01 2 2 4 42 +2000-01-01 1 0 3 -1 1 +2000-01-01 1 1 0 -33 1000 +2000-01-01 1 1 4 -2 10 +2000-01-01 1 2 5 -3 210 +2000-01-01 2 0 3 -1 2 +2000-01-01 2 1 4 -2 20 +2000-01-01 2 2 5 -3 310 +2000-01-01 1 0 3 -1 1 +2000-01-01 1 1 0 -33 1000 +2000-01-01 1 1 4 -2 10 +2000-01-01 1 2 5 -3 210 +2000-01-01 2 0 3 -1 2 +2000-01-01 2 1 4 -2 20 +2000-01-01 2 2 5 -3 310 +2000-01-01 1 0 3 -1 1 +2000-01-01 1 1 0 -33 1000 +2000-01-01 1 1 4 -2 10 +2000-01-01 1 2 5 -3 210 +2000-01-01 2 0 3 -1 2 +2000-01-01 2 1 4 -2 20 +2000-01-01 2 2 5 -3 310 diff --git a/dbms/tests/queries/0_stateless/00327_summing_composite_nested.sql b/dbms/tests/queries/0_stateless/00327_summing_composite_nested.sql new file mode 100644 index 00000000000..a9ea7d399a7 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00327_summing_composite_nested.sql @@ -0,0 +1,37 @@ +DROP TABLE IF EXISTS test.summing_composite_key; +CREATE TABLE test.summing_composite_key (d Date, k UInt64, FirstMap Nested(k1 UInt32, k2ID Int8, s Float64), SecondMap Nested(k1ID UInt64, k2Key UInt32, k3Type Int32, s Int64)) ENGINE = SummingMergeTree(d, k, 1); + +INSERT INTO test.summing_composite_key VALUES ('2000-01-01', 1, [1,2], [3,4], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]); +INSERT INTO test.summing_composite_key VALUES ('2000-01-01', 1, [2,1], [4,3], [20,22], [2,2,1], [5,5,0], [-3,-3,-33], [10,100,1000]); + +INSERT INTO test.summing_composite_key VALUES ('2000-01-01', 2, [1,2], [3,4], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]); +INSERT INTO test.summing_composite_key VALUES ('2000-01-01', 2, [2,1,1], [4,3,3], [20,22,33], [2,2], [5,5], [-3,-3], [10,100]); +INSERT INTO test.summing_composite_key VALUES ('2000-01-01', 2, [1,2], [3,4], [10,11], [0,1,2], [3,4,5], [-1,-2,-3], [1,10,100]); + +SELECT * FROM test.summing_composite_key ORDER BY d, k, _part_index; + +SELECT d, k, m.k1, m.k2ID, m.s FROM test.summing_composite_key ARRAY JOIN FirstMap AS m ORDER BY d, k, m.k1, m.k2ID, m.s; +SELECT d, k, m.k1, m.k2ID, sum(m.s) FROM test.summing_composite_key ARRAY JOIN FirstMap AS m GROUP BY d, k, m.k1, m.k2ID ORDER BY d, k, m.k1, m.k2ID; +SELECT d, k, m.k1, m.k2ID,m. s FROM test.summing_composite_key FINAL ARRAY JOIN FirstMap AS m ORDER BY d, k, m.k1, m.k2ID, m.s; + +SELECT d, k, m.k1ID, m.k2Key, m.k3Type, m.s FROM test.summing_composite_key ARRAY JOIN SecondMap AS m ORDER BY d, k, m.k1ID, m.k2Key, m.k3Type, m.s; +SELECT d, k, m.k1ID, m.k2Key, m.k3Type, sum(m.s) FROM test.summing_composite_key ARRAY JOIN SecondMap AS m GROUP BY d, k, m.k1ID, m.k2Key, m.k3Type ORDER BY d, k, m.k1ID, m.k2Key, m.k3Type; +SELECT d, k, m.k1ID, m.k2Key, m.k3Type, m.s FROM test.summing_composite_key FINAL ARRAY JOIN SecondMap AS m ORDER BY d, k, m.k1ID, m.k2Key, m.k3Type, m.s; + +OPTIMIZE TABLE test.summing_composite_key; +OPTIMIZE TABLE test.summing_composite_key; +OPTIMIZE TABLE test.summing_composite_key; +OPTIMIZE TABLE test.summing_composite_key; +OPTIMIZE TABLE test.summing_composite_key; + +SELECT * FROM test.summing_composite_key ORDER BY d, k, _part_index; + +SELECT d, k, m.k1, m.k2ID, m.s FROM test.summing_composite_key ARRAY JOIN FirstMap AS m ORDER BY d, k, m.k1, m.k2ID, m.s; +SELECT d, k, m.k1, m.k2ID, sum(m.s) FROM test.summing_composite_key ARRAY JOIN FirstMap AS m GROUP BY d, k, m.k1, m.k2ID ORDER BY d, k, m.k1, m.k2ID; +SELECT d, k, m.k1, m.k2ID, m.s FROM test.summing_composite_key FINAL ARRAY JOIN FirstMap AS m ORDER BY d, k, m.k1, m.k2ID, m.s; + +SELECT d, k, m.k1ID, m.k2Key, m.k3Type, m.s FROM test.summing_composite_key ARRAY JOIN SecondMap AS m ORDER BY d, k, m.k1ID, m.k2Key, m.k3Type, m.s; +SELECT d, k, m.k1ID, m.k2Key, m.k3Type, sum(m.s) FROM test.summing_composite_key ARRAY JOIN SecondMap AS m GROUP BY d, k, m.k1ID, m.k2Key, m.k3Type ORDER BY d, k, m.k1ID, m.k2Key, m.k3Type; +SELECT d, k, m.k1ID, m.k2Key, m.k3Type, m.s FROM test.summing_composite_key FINAL ARRAY JOIN SecondMap AS m ORDER BY d, k, m.k1ID, m.k2Key, m.k3Type, m.s; + +DROP TABLE test.summing_composite_key;