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:
alexey-milovidov 2020-04-27 13:10:27 +03:00 committed by GitHub
commit 4a60cc6b2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View File

@ -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);

View File

@ -0,0 +1,4 @@
1557136800 1557169200
1
1
1

View File

@ -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;