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>
|
2013-10-25 14:56:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2018-09-20 15:35:52 +00:00
|
|
|
/** This stream adds three types of columns into block
|
|
|
|
* 1. Columns, that are missed inside request, but present in table without defaults (missed columns)
|
|
|
|
* 2. Columns, that are missed inside request, but present in table with defaults (columns with default values)
|
|
|
|
* 3. Columns that materialized from other columns (materialized columns)
|
|
|
|
* All three types of 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_,
|
2018-09-20 15:35:52 +00:00
|
|
|
const Block & output_block_,
|
2017-04-01 07:20:54 +00:00
|
|
|
const ColumnDefaults & column_defaults_,
|
2018-03-10 00:11:39 +00:00
|
|
|
const Context & context_)
|
2018-09-20 15:35:52 +00:00
|
|
|
: output(output_), header(header_), output_block(output_block_),
|
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-09-20 15:35:52 +00:00
|
|
|
const Block header;
|
|
|
|
/// Blocks after this stream should have this structure
|
|
|
|
const Block output_block;
|
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
|
|
|
}
|