From d27951b4a7081b8f26fb8f53b83182cb1bd24ff6 Mon Sep 17 00:00:00 2001 From: Vitaliy Lyudvichenko Date: Wed, 23 Nov 2016 16:33:05 +0300 Subject: [PATCH] Added requested changes. [#METR-23473] --- dbms/include/DB/Storages/MergeTree/PKCondition.h | 2 +- .../src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp | 7 +++---- dbms/src/Storages/MergeTree/PKCondition.cpp | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dbms/include/DB/Storages/MergeTree/PKCondition.h b/dbms/include/DB/Storages/MergeTree/PKCondition.h index 1ba0db3058e..bc5270c45f5 100644 --- a/dbms/include/DB/Storages/MergeTree/PKCondition.h +++ b/dbms/include/DB/Storages/MergeTree/PKCondition.h @@ -224,7 +224,7 @@ public: /// Не учитывает секцию SAMPLE. all_columns - набор всех столбцов таблицы. PKCondition(ASTPtr & query, const Context & context, const NamesAndTypesList & all_columns, const SortDescription & sort_descr, - const Block & pk_sample_block); + const Block & pk_sample_block = Block()); /// Выполнимо ли условие в диапазоне ключей. /// left_pk и right_pk должны содержать все поля из sort_descr в соответствующем порядке. diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp index 2e2b94bee50..8516d38c53d 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp @@ -195,11 +195,10 @@ BlockInputStreams MergeTreeDataSelectExecutor::read( SortDescription sort_descr = data.getSortDescription(); - Block pk_sample_block = data.getPrimaryExpression()->getSampleBlock(); - - PKCondition key_condition(query, context, available_real_and_virtual_columns, sort_descr, pk_sample_block); + PKCondition key_condition(query, context, available_real_and_virtual_columns, sort_descr, + data.getPrimaryExpression()->getSampleBlock()); PKCondition date_condition(query, context, available_real_and_virtual_columns, - SortDescription(1, SortColumnDescription(data.date_column_name, 1)), pk_sample_block); + SortDescription(1, SortColumnDescription(data.date_column_name, 1))); if (settings.force_primary_key && key_condition.alwaysUnknownOrTrue()) { diff --git a/dbms/src/Storages/MergeTree/PKCondition.cpp b/dbms/src/Storages/MergeTree/PKCondition.cpp index b9faba4be6c..2c9d6711995 100644 --- a/dbms/src/Storages/MergeTree/PKCondition.cpp +++ b/dbms/src/Storages/MergeTree/PKCondition.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -369,7 +370,7 @@ static bool tryCastValueToType(const DataTypePtr & desired_type, const DataTypeP src_value = data_type_enum->castToValue(src_value); } /// Convert 'YYYY-MM-DD' Strings to Date - else if (typeid_cast(desired_type.get())) + else if (typeid_cast(desired_type.get()) || typeid_cast(desired_type.get())) { if (typeid_cast(src_type.get())) {