Added tests [#CLICKHOUSE-3486].

This commit is contained in:
Alexey Milovidov 2017-12-06 07:16:16 +03:00
parent 9b81c1ea66
commit 4a04537d44
4 changed files with 253 additions and 0 deletions

View File

@ -0,0 +1,3 @@
0 40
1 30
2 30

View File

@ -0,0 +1,22 @@
SELECT key2, arrayReduce('uniqExactMerge', arr)
FROM
(
SELECT
key1 % 3 AS key2,
groupArray(state) AS arr
FROM
(
SELECT
number % 10 AS key1,
uniqExactState(number) AS state
FROM
(
SELECT *
FROM system.numbers
LIMIT 100
)
GROUP BY key1
)
GROUP BY key2
)
ORDER BY key2;

View File

@ -0,0 +1,168 @@
2017-01-01 00:00:00
2017-02-01 00:00:00
2017-12-01 00:00:00
2018-01-01 00:00:00
2018-02-01 00:00:00
2016-12-01 00:00:00
2016-02-01 00:00:00
2016-01-01 00:00:00
2015-12-01 00:00:00
2017-01-01 00:00:00
2016-12-01 00:00:00
2016-02-01 00:00:00
2016-01-01 00:00:00
2015-12-01 00:00:00
2017-02-01 00:00:00
2017-12-01 00:00:00
2018-01-01 00:00:00
2018-02-01 00:00:00
2017-01-01
2017-02-01
2017-12-01
2018-01-01
2018-02-01
2016-12-01
2016-02-01
2016-01-01
2015-12-01
2017-01-01
2016-12-01
2016-02-01
2016-01-01
2015-12-01
2017-02-01
2017-12-01
2018-01-01
2018-02-01
2017-01-01 00:00:00
2018-01-01 00:00:00
2016-01-01 00:00:00
2017-01-01 00:00:00
2016-01-01 00:00:00
2018-01-01 00:00:00
2017-01-01
2018-01-01
2016-01-01
2017-01-01
2016-01-01
2018-01-01
2015-10-01
2015-11-01
2015-12-01
2016-01-01
2016-02-01
2016-03-01
2016-04-01
2016-05-01
2016-06-01
2016-07-01
2016-08-01
2016-09-01
2016-10-01
2016-11-01
2016-12-01
2017-01-01
2017-02-01
2017-03-01
2017-04-01
2017-05-01
2017-06-01
2017-07-01
2017-08-01
2017-09-01
2017-10-01
2017-11-01
2017-12-01
2018-01-01
2018-02-01
2018-03-01
2018-04-01
2018-03-01
2018-02-01
2018-01-01
2017-12-01
2017-11-01
2017-10-01
2017-09-01
2017-08-01
2017-07-01
2017-06-01
2017-05-01
2017-04-01
2017-03-01
2017-02-01
2017-01-01
2016-12-01
2016-11-01
2016-10-01
2016-09-01
2016-08-01
2016-07-01
2016-06-01
2016-05-01
2016-04-01
2016-03-01
2016-02-01
2016-01-01
2015-12-01
2015-11-01
2002-01-01
2003-01-01
2004-01-01
2005-01-01
2006-01-01
2007-01-01
2008-01-01
2009-01-01
2010-01-01
2011-01-01
2012-01-01
2013-01-01
2014-01-01
2015-01-01
2016-01-01
2017-01-01
2018-01-01
2019-01-01
2020-01-01
2021-01-01
2022-01-01
2023-01-01
2024-01-01
2025-01-01
2026-01-01
2027-01-01
2028-01-01
2029-01-01
2030-01-01
2031-01-01
2032-01-01
2031-01-01
2030-01-01
2029-01-01
2028-01-01
2027-01-01
2026-01-01
2025-01-01
2024-01-01
2023-01-01
2022-01-01
2021-01-01
2020-01-01
2019-01-01
2018-01-01
2017-01-01
2016-01-01
2015-01-01
2014-01-01
2013-01-01
2012-01-01
2011-01-01
2010-01-01
2009-01-01
2008-01-01
2007-01-01
2006-01-01
2005-01-01
2004-01-01
2003-01-01

View File

@ -0,0 +1,60 @@
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 0 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 1 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 11 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 12 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 13 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -1 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -11 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -12 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -13 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 0 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 1 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 11 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 12 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 13 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -1 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -11 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -12 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -13 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 0 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 1 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 11 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 12 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL 13 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL -1 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL -11 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL -12 MONTH AS x;
SELECT toDate('2017-01-01') + INTERVAL -13 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 0 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 1 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 11 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 12 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL 13 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL -1 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL -11 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL -12 MONTH AS x;
SELECT toDate('2017-01-01') - INTERVAL -13 MONTH AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 0 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL 1 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') + INTERVAL -1 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 0 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL 1 YEAR AS x;
SELECT toDateTime('2017-01-01 00:00:00') - INTERVAL -1 YEAR AS x;
SELECT toDate('2017-01-01') + INTERVAL 0 YEAR AS x;
SELECT toDate('2017-01-01') + INTERVAL 1 YEAR AS x;
SELECT toDate('2017-01-01') + INTERVAL -1 YEAR AS x;
SELECT toDate('2017-01-01') - INTERVAL 0 YEAR AS x;
SELECT toDate('2017-01-01') - INTERVAL 1 YEAR AS x;
SELECT toDate('2017-01-01') - INTERVAL -1 YEAR AS x;
SELECT toDate('2017-01-01') + INTERVAL number - 15 MONTH AS x FROM system.numbers LIMIT 30;
SELECT toDate('2017-01-01') - INTERVAL number - 15 MONTH AS x FROM system.numbers LIMIT 30;
SELECT toDate('2017-01-01') + INTERVAL number - 15 YEAR AS x FROM system.numbers LIMIT 30;
SELECT toDate('2017-01-01') - INTERVAL number - 15 YEAR AS x FROM system.numbers LIMIT 30;