2020-03-10 09:21:55 +00:00
|
|
|
SELECT
|
|
|
|
arrayReduceInRanges(
|
|
|
|
'groupArray',
|
2020-03-11 09:10:39 +00:00
|
|
|
[(1, 3), (2, 3), (3, 3)],
|
2020-03-10 09:21:55 +00:00
|
|
|
['a', 'b', 'c', 'd', 'e']
|
|
|
|
);
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
arrayReduceInRanges(
|
|
|
|
'sum',
|
2020-03-11 09:10:39 +00:00
|
|
|
[
|
|
|
|
(-6, 0), (-4, 0), (-2, 0), (0, 0), (2, 0), (4, 0),
|
|
|
|
(-6, 1), (-4, 1), (-2, 1), (0, 1), (2, 1), (4, 1),
|
|
|
|
(-6, 2), (-4, 2), (-2, 2), (0, 2), (2, 2), (4, 2),
|
|
|
|
(-6, 3), (-4, 3), (-2, 3), (0, 3), (2, 3), (4, 3)
|
|
|
|
],
|
2020-03-10 09:21:55 +00:00
|
|
|
[100, 200, 300, 400]
|
|
|
|
);
|
|
|
|
|
|
|
|
WITH
|
|
|
|
arrayMap(x -> x + 1, range(50)) as data
|
|
|
|
SELECT
|
2020-03-11 09:10:39 +00:00
|
|
|
arrayReduceInRanges('groupArray', [(a, c), (b, d)], data) =
|
2020-03-10 09:21:55 +00:00
|
|
|
[arraySlice(data, a, c), arraySlice(data, b, d)]
|
|
|
|
FROM (
|
|
|
|
SELECT
|
|
|
|
cityHash64(number + 100) % 40 as a,
|
|
|
|
cityHash64(number + 200) % 60 as b,
|
|
|
|
cityHash64(number + 300) % 20 as c,
|
|
|
|
cityHash64(number + 400) % 30 as d
|
|
|
|
FROM numbers(20)
|
|
|
|
);
|