mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
test for #17302
This commit is contained in:
parent
b8a437c35a
commit
ff9e74bf2a
6
tests/queries/0_stateless/01763_ttl_group_by.reference
Normal file
6
tests/queries/0_stateless/01763_ttl_group_by.reference
Normal file
@ -0,0 +1,6 @@
|
||||
206000 0 3 5
|
||||
41200 0 3 1
|
||||
20600 0 3 1
|
||||
206000 0 3 5
|
||||
41200 0 3 1
|
||||
20600 0 3 1
|
26
tests/queries/0_stateless/01763_ttl_group_by.sql
Normal file
26
tests/queries/0_stateless/01763_ttl_group_by.sql
Normal file
@ -0,0 +1,26 @@
|
||||
drop table if exists test_ttl_group_by01763;
|
||||
CREATE TABLE test_ttl_group_by01763
|
||||
(key UInt32, ts DateTime, value UInt32, min_value UInt32 default value, max_value UInt32 default value)
|
||||
ENGINE = MergeTree() PARTITION BY toYYYYMM(ts)
|
||||
ORDER BY (key, toStartOfInterval(ts, toIntervalMinute(3)), ts)
|
||||
TTL ts + INTERVAL 5 MINUTE GROUP BY key, toStartOfInterval(ts, toIntervalMinute(3))
|
||||
SET value = sum(value), min_value = min(min_value), max_value = max(max_value), ts=min(toStartOfInterval(ts, toIntervalMinute(3)));
|
||||
|
||||
INSERT INTO test_ttl_group_by01763(key, ts, value) SELECT number%5 as key, now() - interval 10 minute + number, 1 FROM numbers(100000);
|
||||
INSERT INTO test_ttl_group_by01763(key, ts, value) SELECT number%5 as key, now() - interval 10 minute + number, 0 FROM numbers(1000);
|
||||
INSERT INTO test_ttl_group_by01763(key, ts, value) SELECT number%5 as key, now() - interval 10 minute + number, 3 FROM numbers(1000);
|
||||
INSERT INTO test_ttl_group_by01763(key, ts, value) SELECT number%5 as key, now() - interval 2 month + number, 1 FROM numbers(100000);
|
||||
INSERT INTO test_ttl_group_by01763(key, ts, value) SELECT number%5 as key, now() - interval 2 month + number, 0 FROM numbers(1000);
|
||||
INSERT INTO test_ttl_group_by01763(key, ts, value) SELECT number%5 as key, now() - interval 2 month + number, 3 FROM numbers(1000);
|
||||
|
||||
SELECT sum(value), min(min_value), max(max_value), uniqExact(key) FROM test_ttl_group_by01763;
|
||||
SELECT sum(value), min(min_value), max(max_value), uniqExact(key) FROM test_ttl_group_by01763 where key = 3 ;
|
||||
SELECT sum(value), min(min_value), max(max_value), uniqExact(key) FROM test_ttl_group_by01763 where key = 3 and ts <= today() - interval 30 day ;
|
||||
|
||||
OPTIMIZE TABLE test_ttl_group_by01763 FINAL;
|
||||
|
||||
SELECT sum(value), min(min_value), max(max_value), uniqExact(key) FROM test_ttl_group_by01763;
|
||||
SELECT sum(value), min(min_value), max(max_value), uniqExact(key) FROM test_ttl_group_by01763 where key = 3 ;
|
||||
SELECT sum(value), min(min_value), max(max_value), uniqExact(key) FROM test_ttl_group_by01763 where key = 3 and ts <= today() - interval 30 day ;
|
||||
|
||||
drop table test_ttl_group_by01763;
|
Loading…
Reference in New Issue
Block a user