| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include <DataStreams/IBlockInputStream.h> |
| 4 | #include <iostream> |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | |
| 9 | /// Removes columns other than columns_to_save_ from block, |
| 10 | /// and reorders columns as in columns_to_save_. |
| 11 | /// Functionality is similar to ExpressionBlockInputStream with ExpressionActions containing PROJECT action. |
| 12 | class FilterColumnsBlockInputStream : public IBlockInputStream |
| 13 | { |
| 14 | public: |
| 15 | FilterColumnsBlockInputStream( |
| 16 | const BlockInputStreamPtr & input, const Names & columns_to_save_, bool throw_if_column_not_found_) |
| 17 | : columns_to_save(columns_to_save_), throw_if_column_not_found(throw_if_column_not_found_) |
| 18 | { |
| 19 | children.push_back(input); |
| 20 | } |
| 21 | |
| 22 | String getName() const override |
| 23 | { |
| 24 | return "FilterColumns"; |
| 25 | } |
| 26 | |
| 27 | Block getHeader() const override; |
| 28 | |
| 29 | protected: |
| 30 | Block readImpl() override; |
| 31 | |
| 32 | private: |
| 33 | Names columns_to_save; |
| 34 | bool throw_if_column_not_found; |
| 35 | }; |
| 36 | |
| 37 | } |
| 38 |