mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Fixed comparing Date and DateTime64
This commit is contained in:
parent
5556c48298
commit
0c2d73adcb
@ -1216,7 +1216,10 @@ public:
|
||||
{
|
||||
return res;
|
||||
}
|
||||
else if (isColumnedAsDecimal(left_type) || isColumnedAsDecimal(right_type))
|
||||
else if ((isColumnedAsDecimal(left_type) || isColumnedAsDecimal(right_type))
|
||||
// Comparing Date and DateTime64 requires implicit conversion,
|
||||
// otherwise Date is treated as number.
|
||||
&& !(date_and_datetime && (isDate(left_type) || isDate(right_type))))
|
||||
{
|
||||
// compare
|
||||
if (!allowDecimalComparison(left_type, right_type) && !date_and_datetime)
|
||||
|
@ -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 <= 0 1 0 = 0 1 0 >= 1 1 1 > 1 0 1 != 1 0 1
|
||||
1 DateTime64(1, \'UTC\') < 0 0 0 <= 0 0 0 = 0 0 0 >= 1 1 1 > 1 1 1 != 1 1 1
|
@ -0,0 +1,43 @@
|
||||
SELECT
|
||||
n,
|
||||
toTypeName(dt64) AS dt64_typename,
|
||||
|
||||
'<',
|
||||
dt64 < d,
|
||||
toDate(dt64) < d,
|
||||
dt64 < toDateTime64(d, 1, 'UTC'),
|
||||
|
||||
'<=',
|
||||
dt64 <= d,
|
||||
toDate(dt64) <= d,
|
||||
dt64 <= toDateTime64(d, 1, 'UTC'),
|
||||
|
||||
'=',
|
||||
dt64 = d,
|
||||
toDate(dt64) = d,
|
||||
dt64 = toDateTime64(d, 1, 'UTC'),
|
||||
|
||||
'>=',
|
||||
dt64 >= d,
|
||||
toDate(dt64) >= d,
|
||||
dt64 >= toDateTime64(d, 1, 'UTC'),
|
||||
|
||||
'>',
|
||||
dt64 > d,
|
||||
toDate(dt64) > d,
|
||||
dt64 > toDateTime64(d, 1, 'UTC'),
|
||||
|
||||
'!=',
|
||||
dt64 != d,
|
||||
toDate(dt64) != d,
|
||||
dt64 != toDateTime64(d, 1, 'UTC')
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
number - 1 as n,
|
||||
toDateTime64(toStartOfInterval(now(), toIntervalSecond(1), 'UTC'), 1, 'UTC') AS dt64,
|
||||
toDate(now(), 'UTC') - n as d
|
||||
FROM system.numbers
|
||||
LIMIT 3
|
||||
)
|
||||
FORMAT TabSeparated
|
Loading…
Reference in New Issue
Block a user