Added test for DateTime vs DateTime64 comparison

This commit is contained in:
Vasily Nemkov 2020-12-08 13:51:50 +03:00
parent edc21aacbc
commit 5556c48298
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,3 @@
-1 DateTime64(1, \'UTC\') < 1 1 1 <= 1 1 1 = 0 0 0 >= 0 0 0 > 0 0 0 != 1 1 1
0 DateTime64(1, \'UTC\') < 0 0 0 <= 1 1 1 = 1 1 1 >= 1 1 1 > 0 0 0 != 0 0 0
1 DateTime64(1, \'UTC\') < 0 0 0 <= 0 0 0 = 0 0 0 >= 1 1 1 > 1 1 1 != 1 1 1

View File

@ -0,0 +1,42 @@
SELECT
n,
toTypeName(dt64) AS dt64_typename,
'<',
dt64 < dt,
toDateTime(dt64) < dt,
dt64 < toDateTime64(dt, 1, 'UTC'),
'<=',
dt64 <= dt,
toDateTime(dt64) <= dt,
dt64 <= toDateTime64(dt, 1, 'UTC'),
'=',
dt64 = dt,
toDateTime(dt64) = dt,
dt64 = toDateTime64(dt, 1, 'UTC'),
'>=',
dt64 >= dt,
toDateTime(dt64) >= dt,
dt64 >= toDateTime64(dt, 1, 'UTC'),
'>',
dt64 > dt,
toDateTime(dt64) > dt,
dt64 > toDateTime64(dt, 1, 'UTC'),
'!=',
dt64 != dt,
toDateTime(dt64) != dt,
dt64 != toDateTime64(dt, 1, 'UTC')
FROM
(
SELECT
number - 1 as n,
toDateTime64(toStartOfInterval(now(), toIntervalSecond(1), 'UTC'), 1, 'UTC') + n AS dt64,
toStartOfInterval(now(), toIntervalSecond(1), 'UTC') AS dt
FROM system.numbers
LIMIT 3
)