Fix totals with rollup.

This commit is contained in:
Nikolai Kochetov 2019-04-29 13:00:17 +03:00
parent 4d87fd327f
commit 0b8107c497
2 changed files with 13 additions and 9 deletions

View File

@ -1637,8 +1637,12 @@ void InterpreterSelectQuery::executeHaving(Pipeline & pipeline, const Expression
void InterpreterSelectQuery::executeHaving(QueryPipeline & pipeline, const ExpressionActionsPtr & expression)
{
pipeline.addSimpleTransform([&](const Block & header)
pipeline.addSimpleTransform([&](const Block & header, QueryPipeline::StreamType stream_type) -> ProcessorPtr
{
if (stream_type == QueryPipeline::StreamType::Totals)
return nullptr;
/// TODO: do we need to save filter there?
return std::make_shared<FilterTransform>(header, expression, getSelectQuery().having_expression->getColumnName(), false);
});
}
@ -1731,7 +1735,7 @@ void InterpreterSelectQuery::executeRollupOrCube(QueryPipeline & pipeline, Modif
pipeline.addSimpleTransform([&](const Block & header, QueryPipeline::StreamType stream_type) -> ProcessorPtr
{
if (stream_type != QueryPipeline::StreamType::Main)
if (stream_type == QueryPipeline::StreamType::Totals)
return nullptr;
if (modificator == Modificator::ROLLUP)

View File

@ -58,7 +58,7 @@ TotalsHavingTransform::TotalsHavingTransform(
finalizeBlock(finalized_header);
/// Port for Totals.
outputs.emplace_back(outputs.front().getHeader(), this);
outputs.emplace_back(finalized_header, this);
/// Initialize current totals with initial state.
current_totals.reserve(header.columns());
@ -258,12 +258,12 @@ void TotalsHavingTransform::prepareTotals()
totals = Chunk(std::move(current_totals), 1);
finalizeChunk(totals);
if (expression)
{
auto block = finalized_header.cloneWithColumns(totals.detachColumns());
expression->execute(block);
totals = Chunk(block.getColumns(), 1);
}
// if (expression)
// {
// auto block = finalized_header.cloneWithColumns(totals.detachColumns());
// expression->execute(block);
// totals = Chunk(block.getColumns(), 1);
// }
}
}