ClickHouse/dbms/DataStreams/FilterColumnsBlockInputStream.h

38 lines
917 B
C++
Raw Normal View History

#pragma once
#include <DataStreams/IBlockInputStream.h>
#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.
class FilterColumnsBlockInputStream : public IBlockInputStream
{
public:
FilterColumnsBlockInputStream(
const BlockInputStreamPtr & input, const Names & columns_to_save_, bool throw_if_column_not_found_)
: columns_to_save(columns_to_save_), throw_if_column_not_found(throw_if_column_not_found_)
{
children.push_back(input);
}
2017-07-04 16:01:45 +00:00
String getName() const override
{
2018-02-21 20:23:27 +00:00
return "FilterColumns";
}
Block getHeader() const override;
protected:
Block readImpl() override;
private:
Names columns_to_save;
bool throw_if_column_not_found;
};
}