mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#pragma once
|
||
|
||
#include <Poco/SharedPtr.h>
|
||
|
||
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
||
#include <DB/Columns/ColumnConst.h>
|
||
|
||
|
||
|
||
namespace DB
|
||
{
|
||
|
||
|
||
/** Добавляет в блок недостающие столбцы со значениями по-умолчанию.
|
||
* Эти столбцы - материалированные (не константы).
|
||
*/
|
||
class AddingDefaultBlockInputStream : public IProfilingBlockInputStream
|
||
{
|
||
public:
|
||
AddingDefaultBlockInputStream(
|
||
BlockInputStreamPtr input_,
|
||
NamesAndTypesListPtr required_columns_)
|
||
: required_columns(required_columns_)
|
||
{
|
||
children.push_back(input_);
|
||
}
|
||
|
||
String getName() const { return "AddingDefaultBlockInputStream"; }
|
||
|
||
String getID() const
|
||
{
|
||
std::stringstream res;
|
||
res << "AddingDefault(" << children.back()->getID();
|
||
|
||
for (NamesAndTypesList::const_iterator it = required_columns->begin(); it != required_columns->end(); ++it)
|
||
res << ", " << it->first << ", " << it->second->getName();
|
||
|
||
res << ")";
|
||
return res.str();
|
||
}
|
||
|
||
protected:
|
||
Block readImpl()
|
||
{
|
||
Block res = children.back()->read();
|
||
if (!res)
|
||
return res;
|
||
res.addDefaults(required_columns);
|
||
return res;
|
||
}
|
||
|
||
private:
|
||
NamesAndTypesListPtr required_columns;
|
||
};
|
||
|
||
}
|