2014-02-11 17:10:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Poco/SharedPtr.h>
|
|
|
|
|
|
|
|
#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_);
|
|
|
|
}
|
|
|
|
|
2014-03-03 08:29:01 +00:00
|
|
|
String getName() const { return "RemoveColumnsBlockInputStream"; }
|
2014-02-11 17:10:48 +00:00
|
|
|
|
|
|
|
String getID() const
|
|
|
|
{
|
|
|
|
std::stringstream res;
|
|
|
|
res << "RemoveColumns(" << children.back()->getID();
|
|
|
|
|
|
|
|
for (const auto & it : columns_to_remove)
|
|
|
|
res << ", " << it;
|
|
|
|
|
|
|
|
res << ")";
|
|
|
|
return res.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Block readImpl()
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|