diff --git a/dbms/src/DataStreams/ExpressionBlockInputStream.cpp b/dbms/src/DataStreams/ExpressionBlockInputStream.cpp index 55b3145266b..7a18b0d5ee0 100644 --- a/dbms/src/DataStreams/ExpressionBlockInputStream.cpp +++ b/dbms/src/DataStreams/ExpressionBlockInputStream.cpp @@ -43,9 +43,7 @@ Block ExpressionBlockInputStream::readImpl() Block res = children.back()->read(); if (!res) return res; - expression->execute(res); - return res; } diff --git a/dbms/src/DataStreams/FilterBlockInputStream.cpp b/dbms/src/DataStreams/FilterBlockInputStream.cpp index 44dd7cdb3d8..22cfd71821b 100644 --- a/dbms/src/DataStreams/FilterBlockInputStream.cpp +++ b/dbms/src/DataStreams/FilterBlockInputStream.cpp @@ -29,9 +29,9 @@ FilterBlockInputStream::FilterBlockInputStream(const BlockInputStreamPtr & input children.push_back(input); /// Determine position of filter column. - Block src_header = expression->getSampleBlock(); - - filter_column = src_header.getPositionByName(filter_column_name); + Block input_header = input->getHeader(); + expression->execute(input_header); + filter_column = input_header.getPositionByName(filter_column_name); } diff --git a/dbms/src/DataStreams/IBlockInputStream.cpp b/dbms/src/DataStreams/IBlockInputStream.cpp index 13a3c99d393..27d76576d49 100644 --- a/dbms/src/DataStreams/IBlockInputStream.cpp +++ b/dbms/src/DataStreams/IBlockInputStream.cpp @@ -64,6 +64,7 @@ void IBlockInputStream::dumpTree(std::ostream & ostr, size_t indent, size_t mult ostr << String(indent, ' ') << getName(); if (multiplier > 1) ostr << " × " << multiplier; + // ostr << ": " << getHeader().dumpStructure(); ostr << std::endl; ++indent; diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp index 1d22bdecd50..bec354f2a8f 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp @@ -473,13 +473,7 @@ BlockInputStreams MergeTreeDataSelectExecutor::read( filter_function->children.push_back(filter_function->arguments); } - /// Add all other columns: expression must save them. - ASTPtr expr_with_filter = std::make_shared(); - for (const auto & name : column_names_to_read) - expr_with_filter->children.push_back(std::make_shared(StringRange(), name)); - expr_with_filter->children.push_back(filter_function); - - filter_expression = ExpressionAnalyzer(expr_with_filter, context, nullptr, available_real_columns).getActions(true); + filter_expression = ExpressionAnalyzer(filter_function, context, nullptr, available_real_columns).getActions(true); /// Add columns needed for `sampling_expression` to `column_names_to_read`. std::vector add_columns = filter_expression->getRequiredColumns();