From 3fa1639877eb94a0ceaa4a1d6d54684f0c0c7623 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 16 Apr 2017 07:38:13 +0300 Subject: [PATCH] ForEach combinator of aggregate functions: more tests [#CLICKHOUSE-2952]. --- .../00447_ForEach_modifier.reference | 3 --- .../0_stateless/00447_ForEach_modifier.sql | 11 --------- .../00447_foreach_modifier.reference | 24 +++++++++++++++++++ .../0_stateless/00447_foreach_modifier.sql | 21 ++++++++++++++++ 4 files changed, 45 insertions(+), 14 deletions(-) delete mode 100644 dbms/tests/queries/0_stateless/00447_ForEach_modifier.reference delete mode 100644 dbms/tests/queries/0_stateless/00447_ForEach_modifier.sql create mode 100644 dbms/tests/queries/0_stateless/00447_foreach_modifier.reference create mode 100644 dbms/tests/queries/0_stateless/00447_foreach_modifier.sql diff --git a/dbms/tests/queries/0_stateless/00447_ForEach_modifier.reference b/dbms/tests/queries/0_stateless/00447_ForEach_modifier.reference deleted file mode 100644 index 28479f4434c..00000000000 --- a/dbms/tests/queries/0_stateless/00447_ForEach_modifier.reference +++ /dev/null @@ -1,3 +0,0 @@ -[4,-1,2] -25 -[4,25,7] diff --git a/dbms/tests/queries/0_stateless/00447_ForEach_modifier.sql b/dbms/tests/queries/0_stateless/00447_ForEach_modifier.sql deleted file mode 100644 index 7bc6128790c..00000000000 --- a/dbms/tests/queries/0_stateless/00447_ForEach_modifier.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE IF NOT EXISTS test.data (sketch Array(Int8)) ENGINE=Memory; - -INSERT INTO test.data VALUES ([-1,-1,-1]), ([4,-1,2]), ([0,25,-1]), ([-1,-1,7]), ([-1,-1,-1]); - -SELECT max(sketch) FROM test.data; - -SELECT maxArray(sketch) FROM test.data; - -SELECT maxForEach(sketch) FROM test.data; - -DROP TABLE test.data; diff --git a/dbms/tests/queries/0_stateless/00447_foreach_modifier.reference b/dbms/tests/queries/0_stateless/00447_foreach_modifier.reference new file mode 100644 index 00000000000..036a2119b25 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00447_foreach_modifier.reference @@ -0,0 +1,24 @@ +[4,-1,2] +25 +[4,25,7] +0 [0,3,6,6,8,10,6,7,8] +1 [0,2,4,6,4,5,6] +2 [0,3,4,6,8,5,6,7] +0 [0,1] +1 [0,3,6,6,4] +2 [0,3,6,9,12,15,12,7] +3 [0,1,2,3,4,5,6,7,8] +0 [[0,0,0],[1,1,1],[2,2,2],[3,3],[4,4],[5,5],[6],[7],[8]] +1 [[0,0,0],[1,1],[2,2],[3,3],[4],[5],[6]] +2 [[0,0,0],[1,1,1],[2,2],[3,3],[4,4],[5],[6],[7]] +0 [[0,0],[1]] +1 [[0,0,0],[1,1,1],[2,2,2],[3,3],[4]] +2 [[0,0,0],[1,1,1],[2,2,2],[3,3,3],[4,4,4],[5,5,5],[6,6],[7]] +3 [[0],[1],[2],[3],[4],[5],[6],[7],[8]] +0 [['0','0','0'],['1','1','1'],['2','2','2'],['3','3'],['4','4'],['5','5'],['6'],['7'],['8']] +1 [['0','0','0'],['1','1'],['2','2'],['3','3'],['4'],['5'],['6']] +2 [['0','0','0'],['1','1','1'],['2','2'],['3','3'],['4','4'],['5'],['6'],['7']] +0 [['0','0'],['1']] +1 [['0','0','0'],['1','1','1'],['2','2','2'],['3','3'],['4']] +2 [['0','0','0'],['1','1','1'],['2','2','2'],['3','3','3'],['4','4','4'],['5','5','5'],['6','6'],['7']] +3 [['0'],['1'],['2'],['3'],['4'],['5'],['6'],['7'],['8']] diff --git a/dbms/tests/queries/0_stateless/00447_foreach_modifier.sql b/dbms/tests/queries/0_stateless/00447_foreach_modifier.sql new file mode 100644 index 00000000000..976639e2b4b --- /dev/null +++ b/dbms/tests/queries/0_stateless/00447_foreach_modifier.sql @@ -0,0 +1,21 @@ +CREATE TABLE IF NOT EXISTS test.data (sketch Array(Int8)) ENGINE=Memory; + +INSERT INTO test.data VALUES ([-1,-1,-1]), ([4,-1,2]), ([0,25,-1]), ([-1,-1,7]), ([-1,-1,-1]); + +SELECT max(sketch) FROM test.data; + +SELECT maxArray(sketch) FROM test.data; + +SELECT maxForEach(sketch) FROM test.data; + +DROP TABLE test.data; + + +SELECT k, sumForEach(arr) FROM (SELECT number % 3 AS k, range(number) AS arr FROM system.numbers LIMIT 10) GROUP BY k ORDER BY k; +SELECT k, sumForEach(arr) FROM (SELECT intDiv(number, 3) AS k, range(number) AS arr FROM system.numbers LIMIT 10) GROUP BY k ORDER BY k; + +SELECT k, groupArrayForEach(arr) FROM (SELECT number % 3 AS k, range(number) AS arr FROM system.numbers LIMIT 10) GROUP BY k ORDER BY k; +SELECT k, groupArrayForEach(arr) FROM (SELECT intDiv(number, 3) AS k, range(number) AS arr FROM system.numbers LIMIT 10) GROUP BY k ORDER BY k; + +SELECT k, groupArrayForEach(arr) FROM (SELECT number % 3 AS k, arrayMap(x -> toString(x), range(number)) AS arr FROM system.numbers LIMIT 10) GROUP BY k ORDER BY k; +SELECT k, groupArrayForEach(arr) FROM (SELECT intDiv(number, 3) AS k, arrayMap(x -> toString(x), range(number)) AS arr FROM system.numbers LIMIT 10) GROUP BY k ORDER BY k;