mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #10515 from ClickHouse/compare-date-time-with-string-literal
Use time zone when comparing DateTime with string literal
This commit is contained in:
commit
4a60cc6b2c
@ -849,7 +849,7 @@ private:
|
||||
{
|
||||
time_t date_time;
|
||||
ReadBufferFromMemory in(string_value.data, string_value.size);
|
||||
readDateTimeText(date_time, in);
|
||||
readDateTimeText(date_time, in, dynamic_cast<const DataTypeDateTime &>(*number_type).getTimeZone());
|
||||
if (!in.eof())
|
||||
throw Exception("String is too long for DateTime: " + string_value.toString(), ErrorCodes::TOO_LARGE_STRING_SIZE);
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
1557136800 1557169200
|
||||
1
|
||||
1
|
||||
1
|
@ -0,0 +1,29 @@
|
||||
DROP TABLE IF EXISTS tztest;
|
||||
|
||||
CREATE TABLE tztest
|
||||
(
|
||||
timeBerlin DateTime('Europe/Berlin'),
|
||||
timeLA DateTime('America/Los_Angeles')
|
||||
)
|
||||
ENGINE = Memory;
|
||||
|
||||
INSERT INTO tztest (timeBerlin, timeLA) VALUES ('2019-05-06 12:00:00', '2019-05-06 12:00:00');
|
||||
|
||||
SELECT
|
||||
toUnixTimestamp(timeBerlin),
|
||||
toUnixTimestamp(timeLA)
|
||||
FROM tztest;
|
||||
|
||||
SELECT 1
|
||||
FROM tztest
|
||||
WHERE timeBerlin = '2019-05-06 12:00:00';
|
||||
|
||||
SELECT 1
|
||||
FROM tztest
|
||||
WHERE timeLA = '2019-05-06 12:00:00';
|
||||
|
||||
SELECT 1
|
||||
FROM tztest
|
||||
WHERE '2019-05-06 12:00:00' = timeBerlin;
|
||||
|
||||
DROP TABLE tztest;
|
Loading…
Reference in New Issue
Block a user