movingSum fix test for blocks order

This commit is contained in:
unknown 2019-06-12 09:53:23 -04:00
parent 9379132afe
commit 1ebc5377f8
2 changed files with 28 additions and 10 deletions

View File

@ -1,3 +1,19 @@
k dt v
b 2001-02-03 01:00:00 5
b 2001-02-03 01:00:01 6
b 2001-02-03 01:00:02 7
b 2001-02-03 01:00:03 8
b 2001-02-03 01:00:04 9
a 2001-02-03 00:00:00 0
a 2001-02-03 00:00:01 1
a 2001-02-03 00:00:02 2
a 2001-02-03 00:00:03 3
a 2001-02-03 00:00:04 4
b 2001-02-03 00:00:00 0
b 2001-02-03 00:00:01 1
b 2001-02-03 00:00:02 2
b 2001-02-03 00:00:03 3
b 2001-02-03 00:00:04 4
k movingSum(v)
String Array(UInt64)
a [0,1,3,6,10]
@ -7,10 +23,10 @@ String Array(UInt64)
a [0,1,3,6,9]
b [0,1,3,6,9,12,15,18,21,24]
k movingSum(v)
String Array(Decimal(18, 2))
a [0.00,1.00,3.00,6.00,10.00]
b [0.00,1.00,3.00,6.00,10.00,15.00,21.00,28.00,36.00,45.00]
String Array(UInt64)
a [0,1,3,6,10]
b [0,1,3,6,10,15,21,28,36,45]
k movingSum(v)
String Array(Decimal(18, 2))
a [0.00,1.00,3.00,6.00,10.00]
b [0.00,1.00,3.00,6.00,10.00,15.00,21.00,28.00,36.00,45.00]
String Array(UInt64)
a [0,1,3,6,10]
b [0,1,3,6,10,15,21,28,36,45]

View File

@ -22,15 +22,17 @@ INSERT INTO moving_sum_num
FROM system.numbers
LIMIT 5;
SELECT k, movingSum(v) FROM moving_sum_num GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes;
SELECT k, movingSum(3)(v) FROM moving_sum_num GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes;
SELECT * FROM moving_sum_num FORMAT TabSeparatedWithNames;
SELECT k, movingSum(v) FROM (SELECT * FROM moving_sum_num ORDER BY k, dt) GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes;
SELECT k, movingSum(3)(v) FROM (SELECT * FROM moving_sum_num ORDER BY k, dt) GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes;
CREATE TABLE moving_sum_dec ENGINE = Memory AS
SELECT k, dt, toDecimal64(v, 2) as v
FROM moving_sum_num;
SELECT k, movingSum(v) FROM moving_sum_dec GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes;
SELECT k, movingSum(v) FROM moving_sum_dec GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes;
SELECT k, movingSum(v) FROM (SELECT * FROM moving_sum_num ORDER BY k, dt) GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes;
SELECT k, movingSum(v) FROM (SELECT * FROM moving_sum_num ORDER BY k, dt) GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes;
DROP TABLE moving_sum_dec;
DROP TABLE moving_sum_num;