From afdc9635cb1183c6c37e3ccd804b5a8ca6498311 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Fri, 29 Jan 2021 19:12:53 +0300 Subject: [PATCH] Update MergeTreeRangeReader --- src/Interpreters/InterpreterSelectQuery.cpp | 6 ++++++ src/Storages/MergeTree/MergeTreeRangeReader.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index db0edefb5e8..6a0e2515801 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -1579,6 +1579,12 @@ void InterpreterSelectQuery::executeFetchColumns(QueryProcessingStage::Enum proc std::make_shared(expressions.filter_info->actions_dag), expressions.filter_info->column_name); + if (alias_actions) + { + query_info.prewhere_info_list->back().alias_actions = std::make_shared(alias_actions); + alias_actions = nullptr; + } + auto & new_filter_info = query_info.prewhere_info_list->front(); new_filter_info.remove_prewhere_column = expressions.filter_info->do_remove_column; diff --git a/src/Storages/MergeTree/MergeTreeRangeReader.cpp b/src/Storages/MergeTree/MergeTreeRangeReader.cpp index afbc28e6883..14ab70a992c 100644 --- a/src/Storages/MergeTree/MergeTreeRangeReader.cpp +++ b/src/Storages/MergeTree/MergeTreeRangeReader.cpp @@ -860,7 +860,7 @@ Columns MergeTreeRangeReader::continueReadingChain(ReadResult & result, size_t & void MergeTreeRangeReader::executePrewhereActionsAndFilterColumns(ReadResult & result) { - if (prewhere_info_list->empty()) + if (!prewhere_info_list || prewhere_info_list->empty()) return; const auto & header = merge_tree_reader->getColumns();