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
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-05-13 22:19:04 +00:00
|
|
|
/** Adds missing columns to the block with default values.
|
|
|
|
* These columns are materialized (not constants).
|
2013-10-25 14:56:47 +00:00
|
|
|
*/
|
|
|
|
class AddingDefaultBlockOutputStream : public IBlockOutputStream
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
AddingDefaultBlockOutputStream(
|
2017-09-08 03:47:27 +00:00
|
|
|
const BlockOutputStreamPtr & output_,
|
2018-02-19 00:45:32 +00:00
|
|
|
const Block & header_,
|
2017-12-25 21:57:29 +00:00
|
|
|
NamesAndTypesList required_columns_,
|
2017-04-01 07:20:54 +00:00
|
|
|
const ColumnDefaults & column_defaults_,
|
2018-03-10 00:11:39 +00:00
|
|
|
const Context & context_)
|
2018-02-19 00:45:32 +00:00
|
|
|
: output(output_), header(header_), required_columns(required_columns_),
|
2018-03-10 00:11:39 +00:00
|
|
|
column_defaults(column_defaults_), context(context_)
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
}
|
2013-10-25 14:56:47 +00:00
|
|
|
|
2018-02-19 00:45:32 +00:00
|
|
|
Block getHeader() const override { return header; }
|
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;
|
2018-02-19 00:45:32 +00:00
|
|
|
Block header;
|
2017-12-25 21:57:29 +00:00
|
|
|
NamesAndTypesList required_columns;
|
2017-04-01 07:20:54 +00:00
|
|
|
const ColumnDefaults column_defaults;
|
2017-09-04 17:49:39 +00:00
|
|
|
const Context & context;
|
2013-10-25 14:56:47 +00:00
|
|
|
};
|
|
|
|
|
2013-10-28 14:15:56 +00:00
|
|
|
|
2013-10-25 14:56:47 +00:00
|
|
|
}
|