From dba529d6747068dd07c812cbecf7da2b1edee8e8 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 17 Feb 2018 07:13:49 +0300 Subject: [PATCH] Header in every stream: development [#CLICKHOUSE-2] --- dbms/src/DataStreams/ExpressionBlockInputStream.cpp | 2 -- dbms/src/DataStreams/FilterBlockInputStream.cpp | 6 +++--- dbms/src/DataStreams/IBlockInputStream.cpp | 1 + .../Storages/MergeTree/MergeTreeDataSelectExecutor.cpp | 8 +------- 4 files changed, 5 insertions(+), 12 deletions(-) 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();