2013-10-25 14:56:47 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <Poco/SharedPtr.h>
|
|
|
|
|
|
|
|
|
|
#include <DB/DataStreams/IBlockOutputStream.h>
|
|
|
|
|
#include <DB/Columns/ColumnConst.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Добавляет в блок недостающие столбцы со значениями по-умолчанию.
|
|
|
|
|
* Эти столбцы - материалированные (не константы).
|
|
|
|
|
*/
|
|
|
|
|
class AddingDefaultBlockOutputStream : public IBlockOutputStream
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AddingDefaultBlockOutputStream(
|
|
|
|
|
BlockOutputStreamPtr output_,
|
|
|
|
|
NamesAndTypesListPtr required_columns_)
|
|
|
|
|
: output(output_), required_columns(required_columns_)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getName() const { return "AddingDefaultBlockOutputStream"; }
|
|
|
|
|
|
2013-10-31 18:38:34 +00:00
|
|
|
|
void write(const Block & block)
|
|
|
|
|
{
|
2013-10-25 14:56:47 +00:00
|
|
|
|
Block res = block;
|
2013-10-28 16:09:42 +00:00
|
|
|
|
res.addDefaults(required_columns);
|
2013-10-31 18:38:34 +00:00
|
|
|
|
output->write(res);
|
2013-10-25 14:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
BlockOutputStreamPtr output;
|
|
|
|
|
NamesAndTypesListPtr required_columns;
|
|
|
|
|
};
|
|
|
|
|
|
2013-10-28 14:15:56 +00:00
|
|
|
|
|
2013-10-25 14:56:47 +00:00
|
|
|
|
}
|