mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 03:22:14 +00:00
51 lines
1019 B
C++
51 lines
1019 B
C++
#pragma once
|
|
|
|
#include <DB/Columns/ColumnConst.h>
|
|
|
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Преобразует столбцы-константы в полноценные столбцы ("материализует" их).
|
|
*/
|
|
class MaterializingBlockInputStream : public IProfilingBlockInputStream
|
|
{
|
|
public:
|
|
MaterializingBlockInputStream(BlockInputStreamPtr input_)
|
|
{
|
|
children.push_back(input_);
|
|
}
|
|
|
|
String getName() const { return "MaterializingBlockInputStream"; }
|
|
|
|
String getID() const
|
|
{
|
|
std::stringstream res;
|
|
res << "Materializing(" << children.back()->getID() << ")";
|
|
return res.str();
|
|
}
|
|
|
|
protected:
|
|
Block readImpl()
|
|
{
|
|
Block res = children.back()->read();
|
|
|
|
if (!res)
|
|
return res;
|
|
|
|
size_t columns = res.columns();
|
|
for (size_t i = 0; i < columns; ++i)
|
|
{
|
|
ColumnPtr col = res.getByPosition(i).column;
|
|
if (col->isConst())
|
|
res.getByPosition(i).column = dynamic_cast<IColumnConst &>(*col).convertToFullColumn();
|
|
}
|
|
|
|
return res;
|
|
}
|
|
};
|
|
|
|
}
|