ClickHouse/dbms/src/DataStreams/ExpressionBlockInputStream.cpp
Nikolai Kochetov 2684bd0d5e Fixes for 7216
2019-10-11 20:27:54 +03:00

48 lines
1.0 KiB
C++

#include <Interpreters/ExpressionActions.h>
#include <DataStreams/ExpressionBlockInputStream.h>
namespace DB
{
ExpressionBlockInputStream::ExpressionBlockInputStream(const BlockInputStreamPtr & input, const ExpressionActionsPtr & expression_)
: expression(expression_)
{
children.push_back(input);
cached_header = children.back()->getHeader();
expression->execute(cached_header, true);
}
String ExpressionBlockInputStream::getName() const { return "Expression"; }
Block ExpressionBlockInputStream::getTotals()
{
totals = children.back()->getTotals();
expression->executeOnTotals(totals);
return totals;
}
Block ExpressionBlockInputStream::getHeader() const
{
return cached_header.cloneEmpty();
}
Block ExpressionBlockInputStream::readImpl()
{
if (!initialized)
{
if (expression->resultIsAlwaysEmpty())
return {};
initialized = true;
}
Block res = children.back()->read();
if (res)
expression->execute(res);
return res;
}
}