2017-04-01 09:19:00 +00:00
|
|
|
#include <DataStreams/AddingDefaultBlockOutputStream.h>
|
2017-03-11 00:27:59 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Block.h>
|
2017-03-11 00:27:59 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
void AddingDefaultBlockOutputStream::write(const DB::Block & block)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
Block res = block;
|
2017-03-11 00:27:59 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/// Computes explicitly specified values (in column_defaults) by default.
|
|
|
|
/** @todo if somehow block does not contain values for implicitly-defaulted columns that are prerequisites
|
|
|
|
* for explicitly-defaulted ones, exception will be thrown during evaluating such columns
|
|
|
|
* (implicitly-defaulted columns are evaluated on the line after following one. */
|
|
|
|
evaluateMissingDefaults(res, *required_columns, column_defaults, context);
|
2017-03-11 00:27:59 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/// Adds not specified default values.
|
|
|
|
if (!only_explicit_column_defaults)
|
|
|
|
/// @todo this line may be moved before `evaluateMissingDefaults` with passing {required_columns - explicitly-defaulted columns}
|
|
|
|
res.addDefaults(*required_columns);
|
2017-03-11 00:27:59 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
output->write(res);
|
2017-03-11 00:27:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddingDefaultBlockOutputStream::flush()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
output->flush();
|
2017-03-11 00:27:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddingDefaultBlockOutputStream::writePrefix()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
output->writePrefix();
|
2017-03-11 00:27:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddingDefaultBlockOutputStream::writeSuffix()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
output->writeSuffix();
|
2017-03-11 00:27:59 +00:00
|
|
|
}
|
|
|
|
}
|