2013-10-25 14:56:47 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
|
|
|
|
#include <Columns/ColumnConst.h>
|
|
|
|
|
#include <Storages/ColumnDefault.h>
|
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
|
#include <Interpreters/evaluateMissingDefaults.h>
|
2013-10-25 14:56:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Добавляет в блок недостающие столбцы со значениями по-умолчанию.
|
|
|
|
|
* Эти столбцы - материалированные (не константы).
|
|
|
|
|
*/
|
|
|
|
|
class AddingDefaultBlockOutputStream : public IBlockOutputStream
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
|
AddingDefaultBlockOutputStream(
|
|
|
|
|
BlockOutputStreamPtr output_,
|
|
|
|
|
NamesAndTypesListPtr required_columns_,
|
|
|
|
|
const ColumnDefaults & column_defaults_,
|
|
|
|
|
const Context & context_,
|
|
|
|
|
bool only_explicit_column_defaults_)
|
|
|
|
|
: output(output_), required_columns(required_columns_),
|
|
|
|
|
column_defaults(column_defaults_), context(context_),
|
|
|
|
|
only_explicit_column_defaults(only_explicit_column_defaults_)
|
|
|
|
|
{
|
|
|
|
|
}
|
2013-10-25 14:56:47 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
|
void write(const Block & block) override;
|
2013-10-25 14:56:47 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
|
void flush() override;
|
2014-08-14 20:27:41 +00:00
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
|
void writePrefix() override;
|
|
|
|
|
void writeSuffix() override;
|
2014-09-18 19:49:31 +00:00
|
|
|
|
|
2013-10-25 14:56:47 +00:00
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
|
BlockOutputStreamPtr output;
|
|
|
|
|
NamesAndTypesListPtr required_columns;
|
|
|
|
|
const ColumnDefaults column_defaults;
|
|
|
|
|
Context context;
|
|
|
|
|
bool only_explicit_column_defaults;
|
2013-10-25 14:56:47 +00:00
|
|
|
|
};
|
|
|
|
|
|
2013-10-28 14:15:56 +00:00
|
|
|
|
|
2013-10-25 14:56:47 +00:00
|
|
|
|
}
|