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>
|
2020-10-02 12:38:50 +00:00
|
|
|
#include <Storages/ColumnsDescription.h>
|
2013-10-25 14:56:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-02-05 11:41:44 +00:00
|
|
|
class ExpressionActions;
|
|
|
|
using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>;
|
|
|
|
|
2020-05-20 20:16:32 +00:00
|
|
|
class Context;
|
2013-10-25 14:56:47 +00:00
|
|
|
|
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)
|
2021-04-23 12:36:40 +00:00
|
|
|
* Also the stream can substitute NULL into DEFAULT value in case of INSERT SELECT query (null_as_default) if according setting is 1.
|
2018-09-20 15:35:52 +00:00
|
|
|
* 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_,
|
2020-10-02 12:38:50 +00:00
|
|
|
const ColumnsDescription & columns_,
|
2021-04-23 09:50:56 +00:00
|
|
|
ContextPtr context_,
|
|
|
|
bool null_as_default_ = false);
|
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;
|
2021-02-10 12:45:39 +00:00
|
|
|
ExpressionActionsPtr adding_defaults_actions;
|
2013-10-25 14:56:47 +00:00
|
|
|
};
|
|
|
|
|
2013-10-28 14:15:56 +00:00
|
|
|
|
2013-10-25 14:56:47 +00:00
|
|
|
}
|