aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/bigdate/arithmetic.sql
diff options
context:
space:
mode:
authorudovichenko-r <udovichenko-r@yandex-team.com>2024-11-19 14:58:38 +0300
committerudovichenko-r <udovichenko-r@yandex-team.com>2024-11-19 15:16:27 +0300
commit24521403b1c44303e043ba540c09b1fe991c7474 (patch)
tree341d1e7206bc7c143d04d2d96f05b6dc0655606d /yql/essentials/tests/sql/suites/bigdate/arithmetic.sql
parent72b3cd51dc3fb9d16975d353ea82fd85701393cc (diff)
downloadydb-24521403b1c44303e043ba540c09b1fe991c7474.tar.gz
YQL-19206 Move contrib/ydb/library/yql/tests/sql/suites -> yql/essentials/tests/sql/suites
commit_hash:d0ef1f92b09c94db7c2408f946d2a4c62b603f00
Diffstat (limited to 'yql/essentials/tests/sql/suites/bigdate/arithmetic.sql')
-rw-r--r--yql/essentials/tests/sql/suites/bigdate/arithmetic.sql103
1 files changed, 103 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/bigdate/arithmetic.sql b/yql/essentials/tests/sql/suites/bigdate/arithmetic.sql
new file mode 100644
index 0000000000..5e72aa0c06
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/bigdate/arithmetic.sql
@@ -0,0 +1,103 @@
+$date32_min = unwrap(cast(-53375809 as date32));
+$date32_max = unwrap(cast(53375807 as date32));
+$datetime64_min = unwrap(cast(-4611669897600 as datetime64));
+$datetime64_max = unwrap(cast(4611669811199 as datetime64));
+$timestamp64_min = unwrap(cast(-4611669897600000000 as timestamp64));
+$timestamp64_max = unwrap(cast(4611669811199999999 as timestamp64));
+$interval64_min = unwrap(cast(-9223339708799999999 as interval64));
+$interval64_max = unwrap(cast(9223339708799999999 as interval64));
+$interval64_plus1 = unwrap(cast(1 as interval64));
+$interval64_minus1 = unwrap(cast(-1 as interval64));
+$interval64_zero = unwrap(cast(0 as interval64));
+
+$date_max_value = 49673l;
+$date_max = unwrap(cast($date_max_value - 1 as date));
+$datetime_max = unwrap(cast($date_max_value*86400 - 1 as datetime));
+$timestamp_max = unwrap(cast($date_max_value*86400*1000000 - 1 as timestamp));
+$interval_min = unwrap(cast(-$date_max_value*86400*1000000 + 1 as interval));
+$interval_max = unwrap(cast($date_max_value*86400*1000000 - 1 as interval));
+$interval_plus1 = unwrap(cast(1 as interval));
+$interval_minus1 = unwrap(cast(-1 as interval));
+
+$i64_max = 9223372036854775807l;
+$ui64_max = 18446744073709551615ul;
+
+select 1, $date32_min - $date32_max, $date32_max - $date32_min
+, $date32_min - $datetime64_max, $date32_max - $datetime64_min
+, $date32_min - $timestamp64_max, $date32_max - $timestamp64_min
+, 2, $date32_min - $date_max
+, $date32_min - $datetime_max
+, $date32_min - $timestamp_max
+, 3, $date32_min - $interval64_minus1, $date32_max - $interval64_minus1
+, $date32_min - $interval64_plus1, $date32_max - $interval64_plus1
+, $date32_min + $interval64_minus1, $date32_max + $interval64_minus1
+, $date32_min + $interval64_plus1, $date32_max + $interval64_plus1
+, 4, $date32_min - $interval_minus1, $date32_max - $interval_minus1
+, $date32_min - $interval_plus1, $date32_max - $interval_plus1
+, $date32_min + $interval_minus1, $date32_max + $interval_minus1
+, $date32_min + $interval_plus1, $date32_max + $interval_plus1;
+
+select 1, $datetime64_min - $date32_max, $datetime64_max - $date32_min
+, $datetime64_min - $datetime64_max, $datetime64_max - $datetime64_min
+, $datetime64_min - $timestamp64_max, $datetime64_max - $timestamp64_min
+, 2, $datetime64_min - $date_max
+, $datetime64_min - $datetime_max
+, $datetime64_min - $timestamp_max
+, 3, $datetime64_min - $interval64_minus1, $datetime64_max - $interval64_minus1
+, $datetime64_min - $interval64_plus1, $datetime64_max - $interval64_plus1
+, $datetime64_min + $interval64_minus1, $datetime64_max + $interval64_minus1
+, $datetime64_min + $interval64_plus1, $datetime64_max + $interval64_plus1
+, 4, $datetime64_min - $interval_minus1, $datetime64_max - $interval_minus1
+, $datetime64_min - $interval_plus1, $datetime64_max - $interval_plus1
+, $datetime64_min + $interval_minus1, $datetime64_max + $interval_minus1
+, $datetime64_min + $interval_plus1, $datetime64_max + $interval_plus1;
+
+select 1, $timestamp64_min - $date32_max, $timestamp64_max - $date32_min
+, $timestamp64_min - $datetime64_max, $timestamp64_max - $datetime64_min
+, $timestamp64_min - $timestamp64_max, $timestamp64_max - $timestamp64_min
+, 2, $timestamp64_min - $date_max
+, $timestamp64_min - $datetime_max
+, $timestamp64_min - $timestamp_max
+, 3, $timestamp64_min - $interval64_minus1, $timestamp64_max - $interval64_minus1
+, $timestamp64_min - $interval64_plus1, $timestamp64_max - $interval64_plus1
+, $timestamp64_min + $interval64_minus1, $timestamp64_max + $interval64_minus1
+, $timestamp64_min + $interval64_plus1, $timestamp64_max + $interval64_plus1
+, 4, $timestamp64_min - $interval_minus1, $timestamp64_max - $interval_minus1
+, $timestamp64_min - $interval_plus1, $timestamp64_max - $interval_plus1
+, $timestamp64_min + $interval_minus1, $timestamp64_max + $interval_minus1
+, $timestamp64_min + $interval_plus1, $timestamp64_max + $interval_plus1;
+
+select 1, $date_max - $date32_min, $date_max - $datetime64_min, $date_max - $timestamp64_min
+, $date_max - $date32_max, $date_max - $datetime64_max, $date_max - $timestamp64_max
+, $date_max - $interval64_minus1, $date_max + $interval64_minus1
+, $date_max - $interval64_plus1, $date_max + $interval64_plus1
+, 2, $datetime_max - $date32_min, $datetime_max - $datetime64_min, $datetime_max - $timestamp64_min
+, $datetime_max - $date32_max, $datetime_max - $datetime64_max, $datetime_max - $timestamp64_max
+, $datetime_max - $interval64_minus1, $datetime_max + $interval64_minus1
+, $datetime_max - $interval64_plus1, $datetime_max + $interval64_plus1
+, 3, $timestamp_max - $date32_min, $timestamp_max - $datetime64_min, $timestamp_max - $timestamp64_min
+, $timestamp_max - $date32_max, $timestamp_max - $datetime64_max, $timestamp_max - $timestamp64_max
+, $timestamp_max - $interval64_minus1, $timestamp_max + $interval64_minus1
+, $timestamp_max - $interval64_plus1, $timestamp_max + $interval64_plus1;
+
+select 1, $interval_min - $interval64_min, $interval_min + $interval64_min
+, $interval_min - $interval64_max, $interval_min + $interval64_max
+, $interval_max - $interval64_max, $interval_max + $interval64_max
+, $interval_max - $interval64_min, $interval_max + $interval64_min
+, 2, $interval64_max - $interval64_min, $interval64_min - $interval64_max
+, $interval64_max + $interval64_min, $interval64_max + $interval64_max
+, $interval64_min - $interval64_min, $interval64_max - $interval64_max;
+
+select 0, -$interval64_max, -$interval64_min, -$interval64_zero
+, 1, $interval64_max*0, 0*$interval64_max
+, 2, $interval64_max*1, 1*$interval64_max, $interval64_max*(-1), (-1)*$interval64_max
+, 3, $interval64_min*1, 1*$interval64_min, $interval64_min*(-1), (-1)*$interval64_min
+, 4, $interval64_plus1*cast($interval64_max as int64), $interval64_minus1*cast($interval64_min as int64)
+, 5, $interval64_max*$ui64_max, $i64_max*$interval64_max, $interval64_min*$ui64_max, $i64_max*$interval64_min
+, 6, $interval64_zero*$ui64_max, $ui64_max*$interval64_zero, $interval64_zero*$i64_max, $i64_max*$interval64_zero
+, 7, $interval64_max/0, $interval64_min/0, $interval64_max/1, $interval64_min/1, $interval64_max/(-1), $interval64_min/(-1)
+, 8, $interval64_zero/$ui64_max, $interval64_zero/$i64_max, $interval64_plus1/$ui64_max, $interval64_plus1/$i64_max, $interval64_minus1/$ui64_max, $interval64_minus1/$i64_max
+, 9, $interval64_max/cast($interval64_max as int64), $interval64_min/cast($interval64_min as int64)
+, 10, abs($interval64_max), abs($interval64_min), abs($interval64_zero)
+, 11, cast(4294967296l as interval64) * 4294967296l, 4294967296ul * cast(4294967296l as interval64)
+;