movingSum : test added

This commit is contained in:
unknown 2019-06-12 09:13:42 -04:00
parent d75c73ece2
commit 9379132afe
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,16 @@
k movingSum(v)
String Array(UInt64)
a [0,1,3,6,10]
b [0,1,3,6,10,15,21,28,36,45]
k movingSum(3)(v)
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]
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]

View File

@ -0,0 +1,38 @@
DROP TABLE IF EXISTS moving_sum_num;
DROP TABLE IF EXISTS moving_sum_dec;
CREATE TABLE moving_sum_num (
k String,
dt DateTime,
v UInt64
)
ENGINE = MergeTree ORDER BY (k, dt);
INSERT INTO moving_sum_num
SELECT 'b' k, toDateTime('2001-02-03 00:00:00')+number as dt, number as v
FROM system.numbers
LIMIT 5
UNION ALL
SELECT 'a' k, toDateTime('2001-02-03 00:00:00')+number as dt, number as v
FROM system.numbers
LIMIT 5;
INSERT INTO moving_sum_num
SELECT 'b' k, toDateTime('2001-02-03 01:00:00')+number as dt, 5+number as v
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;
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;
DROP TABLE moving_sum_dec;
DROP TABLE moving_sum_num;