ClickHouse/dbms/DataStreams/AddingDefaultBlockOutputStream.h

52 lines
1.5 KiB
C++
Raw Normal View History

2013-10-25 14:56:47 +00:00
#pragma once
#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:
AddingDefaultBlockOutputStream(
const BlockOutputStreamPtr & output_,
const Block & header_,
2018-09-20 15:35:52 +00:00
const Block & output_block_,
const ColumnDefaults & column_defaults_,
const Context & context_)
2018-09-20 15:35:52 +00:00
: output(output_), header(header_), output_block(output_block_),
column_defaults(column_defaults_), context(context_)
{
}
2013-10-25 14:56:47 +00:00
Block getHeader() const override { return header; }
void write(const Block & block) override;
2013-10-25 14:56:47 +00:00
void flush() override;
void writePrefix() override;
void writeSuffix() override;
2013-10-25 14:56:47 +00:00
private:
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;
const ColumnDefaults column_defaults;
const Context & context;
2013-10-25 14:56:47 +00:00
};
2013-10-25 14:56:47 +00:00
}