2014-02-11 17:10:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
|
|
|
#include <DB/Columns/ColumnConst.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2014-03-03 08:29:01 +00:00
|
|
|
/** Удаляет из блока указанные столбцы.
|
2014-02-11 17:10:48 +00:00
|
|
|
*/
|
|
|
|
class RemoveColumnsBlockInputStream : public IProfilingBlockInputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RemoveColumnsBlockInputStream(
|
|
|
|
BlockInputStreamPtr input_,
|
|
|
|
const Names & columns_to_remove_)
|
|
|
|
: columns_to_remove(columns_to_remove_)
|
|
|
|
{
|
|
|
|
children.push_back(input_);
|
|
|
|
}
|
|
|
|
|
2015-06-08 20:22:02 +00:00
|
|
|
String getName() const override { return "RemoveColumns"; }
|
2014-02-11 17:10:48 +00:00
|
|
|
|
2014-11-08 23:52:18 +00:00
|
|
|
String getID() const override
|
2014-02-11 17:10:48 +00:00
|
|
|
{
|
|
|
|
std::stringstream res;
|
|
|
|
res << "RemoveColumns(" << children.back()->getID();
|
|
|
|
|
|
|
|
for (const auto & it : columns_to_remove)
|
|
|
|
res << ", " << it;
|
|
|
|
|
|
|
|
res << ")";
|
|
|
|
return res.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-11-08 23:52:18 +00:00
|
|
|
Block readImpl() override
|
2014-02-11 17:10:48 +00:00
|
|
|
{
|
|
|
|
Block res = children.back()->read();
|
|
|
|
if (!res)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
for (const auto & it : columns_to_remove)
|
|
|
|
if (res.has(it))
|
|
|
|
res.erase(it);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Names columns_to_remove;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|