ForEach combinator of aggregate functions: more tests [#CLICKHOUSE-2952].

This commit is contained in:
Alexey Milovidov 2017-04-16 07:38:13 +03:00
parent 6b5e6104a9
commit 3fa1639877
4 changed files with 45 additions and 14 deletions

View File

@ -1,3 +0,0 @@
[4,-1,2]
25
[4,25,7]

View File

@ -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;

View File

@ -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']]

View File

@ -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;