mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
movingSum : test added
This commit is contained in:
parent
d75c73ece2
commit
9379132afe
16
dbms/tests/queries/0_stateless/00953_moving_sum.reference
Normal file
16
dbms/tests/queries/0_stateless/00953_moving_sum.reference
Normal 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]
|
38
dbms/tests/queries/0_stateless/00953_moving_sum.sql
Normal file
38
dbms/tests/queries/0_stateless/00953_moving_sum.sql
Normal 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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user