2014-10-10 15:45:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/DataStreams/IBlockOutputStream.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-11 21:46:36 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int ILLEGAL_COLUMN;
|
|
|
|
}
|
|
|
|
|
2014-10-10 15:45:43 +00:00
|
|
|
|
|
|
|
/// Throws exception on encountering prohibited column in block
|
|
|
|
class ProhibitColumnsBlockOutputStream : public IBlockOutputStream
|
|
|
|
{
|
|
|
|
public:
|
2014-10-13 14:35:40 +00:00
|
|
|
ProhibitColumnsBlockOutputStream(const BlockOutputStreamPtr & output, const NamesAndTypesList & columns)
|
2014-10-10 15:45:43 +00:00
|
|
|
: output{output}, columns{columns}
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-10-13 14:35:40 +00:00
|
|
|
private:
|
2014-10-10 15:45:43 +00:00
|
|
|
void write(const Block & block) override
|
|
|
|
{
|
2014-12-19 18:33:30 +00:00
|
|
|
for (const auto & column : columns)
|
|
|
|
if (block.has(column.name))
|
2014-10-10 15:45:43 +00:00
|
|
|
throw Exception{"Cannot insert column " + column.name, ErrorCodes::ILLEGAL_COLUMN};
|
|
|
|
|
|
|
|
output->write(block);
|
|
|
|
}
|
|
|
|
|
2014-10-13 14:35:40 +00:00
|
|
|
void flush() override { output->flush(); }
|
2014-10-10 15:45:43 +00:00
|
|
|
|
|
|
|
void writePrefix() override { output->writePrefix(); }
|
|
|
|
void writeSuffix() override { output->writeSuffix(); }
|
|
|
|
|
|
|
|
BlockOutputStreamPtr output;
|
|
|
|
NamesAndTypesList columns;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|