From 0b8107c497824377775b002383c0a0fa042045e7 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Mon, 29 Apr 2019 13:00:17 +0300 Subject: [PATCH] Fix totals with rollup. --- dbms/src/Interpreters/InterpreterSelectQuery.cpp | 8 ++++++-- .../Transforms/TotalsHavingTransform.cpp | 14 +++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index e5cf167e3c3..02687e2f8b1 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -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(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) diff --git a/dbms/src/Processors/Transforms/TotalsHavingTransform.cpp b/dbms/src/Processors/Transforms/TotalsHavingTransform.cpp index 4fd569d5d91..1facf3b8727 100644 --- a/dbms/src/Processors/Transforms/TotalsHavingTransform.cpp +++ b/dbms/src/Processors/Transforms/TotalsHavingTransform.cpp @@ -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); +// } } }