ClickHouse/src/Processors/Transforms/ExpressionTransform.cpp
2021-05-13 16:38:18 +03:00

29 lines
784 B
C++

#include <Processors/Transforms/ExpressionTransform.h>
#include <Interpreters/ExpressionActions.h>
namespace DB
{
Block ExpressionTransform::transformHeader(Block header, const ActionsDAG & expression)
{
return expression.updateHeader(std::move(header));
}
ExpressionTransform::ExpressionTransform(const Block & header_, ExpressionActionsPtr expression_)
: ISimpleTransform(header_, transformHeader(header_, expression_->getActionsDAG()), false)
, expression(std::move(expression_))
{
}
void ExpressionTransform::transform(Chunk & chunk)
{
size_t num_rows = chunk.getNumRows();
auto block = getInputPort().getHeader().cloneWithColumns(chunk.detachColumns());
expression->execute(block, num_rows);
chunk.setColumns(block.getColumns(), num_rows);
}
}