2011-08-22 20:37:21 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-23 14:48:50 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
2017-12-15 00:01:59 +00:00
|
|
|
#include <Columns/FilterDescription.h>
|
2011-08-22 20:37:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-22 20:43:16 +00:00
|
|
|
class ExpressionActions;
|
2011-08-22 20:37:21 +00:00
|
|
|
|
|
|
|
|
2017-05-13 22:19:04 +00:00
|
|
|
/** Implements WHERE, HAVING operations.
|
|
|
|
* A stream of blocks and an expression, which adds to the block one ColumnUInt8 column containing the filtering conditions, are passed as input.
|
|
|
|
* The expression is evaluated and a stream of blocks is returned, which contains only the filtered rows.
|
2011-08-22 20:37:21 +00:00
|
|
|
*/
|
2019-01-23 14:48:50 +00:00
|
|
|
class FilterBlockInputStream : public IBlockInputStream
|
2011-08-22 20:37:21 +00:00
|
|
|
{
|
2016-01-22 20:43:16 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>;
|
2016-01-22 20:43:16 +00:00
|
|
|
|
2011-08-22 20:37:21 +00:00
|
|
|
public:
|
2019-10-11 17:27:54 +00:00
|
|
|
FilterBlockInputStream(const BlockInputStreamPtr & input, ExpressionActionsPtr expression_,
|
|
|
|
String filter_column_name_, bool remove_filter_ = false);
|
2011-09-04 21:23:19 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override;
|
2018-02-23 10:43:24 +00:00
|
|
|
Block getTotals() override;
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override;
|
2013-05-03 10:20:53 +00:00
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override;
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2018-04-16 12:21:36 +00:00
|
|
|
bool remove_filter;
|
|
|
|
|
2011-08-22 20:37:21 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
ExpressionActionsPtr expression;
|
2018-02-18 03:23:48 +00:00
|
|
|
Block header;
|
2019-10-11 17:27:54 +00:00
|
|
|
String filter_column_name;
|
2017-04-01 07:20:54 +00:00
|
|
|
ssize_t filter_column;
|
2017-12-15 00:01:59 +00:00
|
|
|
|
|
|
|
ConstantFilterDescription constant_filter_description;
|
2018-04-12 09:45:24 +00:00
|
|
|
|
|
|
|
Block removeFilterIfNeed(Block && block);
|
2011-08-22 20:37:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|