| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include <DataStreams/IBlockInputStream.h> |
| 4 | #include <Columns/FilterDescription.h> |
| 5 | |
| 6 | |
| 7 | namespace DB |
| 8 | { |
| 9 | |
| 10 | class ExpressionActions; |
| 11 | |
| 12 | |
| 13 | /** Implements WHERE, HAVING operations. |
| 14 | * A stream of blocks and an expression, which adds to the block one ColumnUInt8 column containing the filtering conditions, are passed as input. |
| 15 | * The expression is evaluated and a stream of blocks is returned, which contains only the filtered rows. |
| 16 | */ |
| 17 | class FilterBlockInputStream : public IBlockInputStream |
| 18 | { |
| 19 | private: |
| 20 | using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>; |
| 21 | |
| 22 | public: |
| 23 | FilterBlockInputStream(const BlockInputStreamPtr & input, ExpressionActionsPtr expression_, |
| 24 | String filter_column_name_, bool remove_filter_ = false); |
| 25 | |
| 26 | String getName() const override; |
| 27 | Block getTotals() override; |
| 28 | Block getHeader() const override; |
| 29 | |
| 30 | protected: |
| 31 | Block readImpl() override; |
| 32 | |
| 33 | bool remove_filter; |
| 34 | |
| 35 | private: |
| 36 | ExpressionActionsPtr expression; |
| 37 | Block header; |
| 38 | String filter_column_name; |
| 39 | ssize_t filter_column; |
| 40 | |
| 41 | ConstantFilterDescription constant_filter_description; |
| 42 | |
| 43 | Block removeFilterIfNeed(Block && block); |
| 44 | }; |
| 45 | |
| 46 | } |
| 47 |