From 4a04537d4413d731039d7ff401c7fa71c2756dbb Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 6 Dec 2017 07:16:16 +0300 Subject: [PATCH] Added tests [#CLICKHOUSE-3486]. --- ...gregate_functions_in_group_array.reference | 3 + ...523_aggregate_functions_in_group_array.sql | 22 +++ ..._time_intervals_months_underflow.reference | 168 ++++++++++++++++++ .../00524_time_intervals_months_underflow.sql | 60 +++++++ 4 files changed, 253 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00523_aggregate_functions_in_group_array.reference create mode 100644 dbms/tests/queries/0_stateless/00523_aggregate_functions_in_group_array.sql create mode 100644 dbms/tests/queries/0_stateless/00524_time_intervals_months_underflow.reference create mode 100644 dbms/tests/queries/0_stateless/00524_time_intervals_months_underflow.sql diff --git a/dbms/tests/queries/0_stateless/00523_aggregate_functions_in_group_array.reference b/dbms/tests/queries/0_stateless/00523_aggregate_functions_in_group_array.reference new file mode 100644 index 00000000000..ba048d7e9ad --- /dev/null +++ b/dbms/tests/queries/0_stateless/00523_aggregate_functions_in_group_array.reference @@ -0,0 +1,3 @@ +0 40 +1 30 +2 30 diff --git a/dbms/tests/queries/0_stateless/00523_aggregate_functions_in_group_array.sql b/dbms/tests/queries/0_stateless/00523_aggregate_functions_in_group_array.sql new file mode 100644 index 00000000000..438f1f1999e --- /dev/null +++ b/dbms/tests/queries/0_stateless/00523_aggregate_functions_in_group_array.sql @@ -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; diff --git a/dbms/tests/queries/0_stateless/00524_time_intervals_months_underflow.reference b/dbms/tests/queries/0_stateless/00524_time_intervals_months_underflow.reference new file mode 100644 index 00000000000..6e5555b0df8 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00524_time_intervals_months_underflow.reference @@ -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 diff --git a/dbms/tests/queries/0_stateless/00524_time_intervals_months_underflow.sql b/dbms/tests/queries/0_stateless/00524_time_intervals_months_underflow.sql new file mode 100644 index 00000000000..6b8ecc3a9fb --- /dev/null +++ b/dbms/tests/queries/0_stateless/00524_time_intervals_months_underflow.sql @@ -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;