2017-07-04 14:59:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-23 14:48:50 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
2017-07-04 14:59:01 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-07-04 16:03:15 +00:00
|
|
|
/// Removes columns other than columns_to_save_ from block,
|
|
|
|
/// and reorders columns as in columns_to_save_.
|
|
|
|
/// Functionality is similar to ExpressionBlockInputStream with ExpressionActions containing PROJECT action.
|
2019-01-23 14:48:50 +00:00
|
|
|
class FilterColumnsBlockInputStream : public IBlockInputStream
|
2017-07-04 14:59:01 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FilterColumnsBlockInputStream(
|
2017-09-08 03:47:27 +00:00
|
|
|
const BlockInputStreamPtr & input, const Names & columns_to_save_, bool throw_if_column_not_found_)
|
2017-07-11 13:20:37 +00:00
|
|
|
: columns_to_save(columns_to_save_), throw_if_column_not_found(throw_if_column_not_found_)
|
2017-07-04 14:59:01 +00:00
|
|
|
{
|
2017-09-08 03:47:27 +00:00
|
|
|
children.push_back(input);
|
2017-07-04 14:59:01 +00:00
|
|
|
}
|
|
|
|
|
2017-07-04 16:01:45 +00:00
|
|
|
String getName() const override
|
|
|
|
{
|
2018-02-21 20:23:27 +00:00
|
|
|
return "FilterColumns";
|
2017-07-04 14:59:01 +00:00
|
|
|
}
|
|
|
|
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override;
|
2018-01-06 18:10:44 +00:00
|
|
|
|
2017-07-04 14:59:01 +00:00
|
|
|
protected:
|
2017-07-04 16:53:37 +00:00
|
|
|
Block readImpl() override;
|
2017-07-04 14:59:01 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Names columns_to_save;
|
2017-07-11 13:20:37 +00:00
|
|
|
bool throw_if_column_not_found;
|
2017-07-04 14:59:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|