From 7c705b1a2410da2fc9d5ba328948a8b9b181ea6d Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 12 Jul 2017 19:59:36 +0300 Subject: [PATCH] added RemoveColumnsBlockInputStream --- .../RemoveColumnsBlockInputStream.h | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 dbms/src/DataStreams/RemoveColumnsBlockInputStream.h diff --git a/dbms/src/DataStreams/RemoveColumnsBlockInputStream.h b/dbms/src/DataStreams/RemoveColumnsBlockInputStream.h new file mode 100644 index 00000000000..f84d4ada55a --- /dev/null +++ b/dbms/src/DataStreams/RemoveColumnsBlockInputStream.h @@ -0,0 +1,56 @@ +#pragma once + +#include +#include + + + +namespace DB +{ + +/** Removes the specified columns from the block. + */ +class RemoveColumnsBlockInputStream : public IProfilingBlockInputStream +{ +public: + RemoveColumnsBlockInputStream( + BlockInputStreamPtr input_, + const Names & columns_to_remove_) + : columns_to_remove(columns_to_remove_) + { + children.push_back(input_); + } + + String getName() const override { return "RemoveColumns"; } + + String getID() const override + { + std::stringstream res; + res << "RemoveColumns(" << children.back()->getID(); + + for (const auto & it : columns_to_remove) + res << ", " << it; + + res << ")"; + return res.str(); + } + +protected: + Block readImpl() override + { + Block res = children.back()->read(); + if (!res) + return res; + + for (const auto & it : columns_to_remove) + if (res.has(it)) + res.erase(it); + + return res; + } + +private: + Names columns_to_remove; +}; + +}