Merge pull request #10791 from oandrew/key-condition-source-type

Use src_type for conversion in KeyCondition
This commit is contained in:
Anton Popov 2020-05-12 03:29:43 +03:00 committed by GitHub
commit a1333895eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 2 deletions

View File

@ -710,8 +710,7 @@ static void castValueToType(const DataTypePtr & desired_type, Field & src_value,
try
{
/// NOTE: We don't need accurate info about src_type at this moment
src_value = convertFieldToType(src_value, *desired_type);
src_value = convertFieldToType(src_value, *desired_type, src_type.get());
}
catch (...)
{

View File

@ -0,0 +1,10 @@
['2020-01-01 10:00:00']
['2020-01-02 00:00:00']
['2020-01-01 00:00:00','2020-01-01 10:00:00']
['2020-01-01 00:00:00','2020-01-01 10:00:00','2020-01-02 00:00:00']
['2020-01-01 00:00:00','2020-01-01 10:00:00','2020-01-02 00:00:00']
['2020-01-01 00:00:00','2020-01-01 10:00:00','2020-01-02 00:00:00']
['2020-01-01 00:00:00','2020-01-01 10:00:00','2020-01-02 00:00:00']
[]
[]
[]

View File

@ -0,0 +1,22 @@
DROP TABLE IF EXISTS test.date_datetime_key_condition;
CREATE TABLE test.date_datetime_key_condition (dt DateTime) ENGINE = MergeTree() ORDER BY dt;
INSERT INTO test.date_datetime_key_condition VALUES ('2020-01-01 00:00:00'), ('2020-01-01 10:00:00'), ('2020-01-02 00:00:00');
-- partial
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt > toDate('2020-01-01') AND dt < toDate('2020-01-02');
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt >= toDate('2020-01-02');
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt < toDate('2020-01-02');
-- inside
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt > toDate('2019-01-02');
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt < toDate('2021-01-02');
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt >= toDate('2019-01-02') AND dt < toDate('2021-01-02');
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt > toDate('2019-01-02') OR dt <= toDate('2021-01-02');
-- outside
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt < toDate('2019-01-02');
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt > toDate('2021-01-02');
SELECT groupArray(dt) from test.date_datetime_key_condition WHERE dt < toDate('2019-01-02') OR dt > toDate('2021-01-02');
DROP TABLE test.date_datetime_key_condition;