2017-04-01 09:19:00 +00:00
|
|
|
#include <Interpreters/ExpressionActions.h>
|
|
|
|
#include <DataStreams/ExpressionBlockInputStream.h>
|
2016-01-13 00:32:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-09-08 03:47:27 +00:00
|
|
|
ExpressionBlockInputStream::ExpressionBlockInputStream(const BlockInputStreamPtr & input, const ExpressionActionsPtr & expression_)
|
2017-04-01 07:20:54 +00:00
|
|
|
: expression(expression_)
|
2016-01-13 00:32:59 +00:00
|
|
|
{
|
2017-09-08 02:29:47 +00:00
|
|
|
children.push_back(input);
|
2019-05-16 17:16:25 +00:00
|
|
|
cached_header = children.back()->getHeader();
|
|
|
|
expression->execute(cached_header, true);
|
2016-01-13 00:32:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String ExpressionBlockInputStream::getName() const { return "Expression"; }
|
|
|
|
|
2018-02-23 10:43:24 +00:00
|
|
|
Block ExpressionBlockInputStream::getTotals()
|
2016-01-13 00:32:59 +00:00
|
|
|
{
|
2019-01-23 14:48:50 +00:00
|
|
|
totals = children.back()->getTotals();
|
|
|
|
expression->executeOnTotals(totals);
|
2016-01-13 00:32:59 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return totals;
|
2016-01-13 00:32:59 +00:00
|
|
|
}
|
|
|
|
|
2018-02-18 03:23:48 +00:00
|
|
|
Block ExpressionBlockInputStream::getHeader() const
|
2018-01-06 18:10:44 +00:00
|
|
|
{
|
2019-05-14 18:26:19 +00:00
|
|
|
return cached_header.cloneEmpty();
|
2018-01-06 18:10:44 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 00:32:59 +00:00
|
|
|
Block ExpressionBlockInputStream::readImpl()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
Block res = children.back()->read();
|
2019-06-17 16:27:18 +00:00
|
|
|
if (res)
|
|
|
|
expression->execute(res);
|
2017-04-01 07:20:54 +00:00
|
|
|
return res;
|
2016-01-13 00:32:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|