From 80850909c7daaf586255f9f5218d611e3f1d4848 Mon Sep 17 00:00:00 2001 From: Alexey Arno Date: Thu, 23 Apr 2015 14:07:15 +0300 Subject: [PATCH] Merge --- dbms/include/DB/Interpreters/InterpreterSelectQuery.h | 2 ++ dbms/src/Interpreters/InterpreterSelectQuery.cpp | 2 ++ .../queries/0_stateless/00152_totals_in_subquery.reference | 4 ++++ dbms/tests/queries/0_stateless/00152_totals_in_subquery.sql | 2 ++ 4 files changed, 10 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00152_totals_in_subquery.reference create mode 100644 dbms/tests/queries/0_stateless/00152_totals_in_subquery.sql diff --git a/dbms/include/DB/Interpreters/InterpreterSelectQuery.h b/dbms/include/DB/Interpreters/InterpreterSelectQuery.h index b501043f1a7..e0707951674 100644 --- a/dbms/include/DB/Interpreters/InterpreterSelectQuery.h +++ b/dbms/include/DB/Interpreters/InterpreterSelectQuery.h @@ -123,6 +123,8 @@ private: void executeDistinct( BlockInputStreams & streams, bool before_order, Names columns); void executeSubqueriesInSetsAndJoins(BlockInputStreams & streams, SubqueriesForSets & subqueries_for_sets); + void ignoreWithTotals() { query.group_by_with_totals = false; } + ASTPtr query_ptr; ASTSelectQuery & query; Context context; diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index 8bd7ab4fa10..59db50b0853 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -610,6 +610,8 @@ QueryProcessingStage::Enum InterpreterSelectQuery::executeFetchColumns(BlockInpu interpreter_subquery = new InterpreterSelectQuery( query.table, subquery_context, required_columns, QueryProcessingStage::Complete, subquery_depth + 1); + if (query_analyzer->hasAggregation()) + interpreter_subquery->ignoreWithTotals(); } /// если в настройках установлен default_sample != 1, то все запросы выполняем с сэмплингом diff --git a/dbms/tests/queries/0_stateless/00152_totals_in_subquery.reference b/dbms/tests/queries/0_stateless/00152_totals_in_subquery.reference new file mode 100644 index 00000000000..c2c31d6422c --- /dev/null +++ b/dbms/tests/queries/0_stateless/00152_totals_in_subquery.reference @@ -0,0 +1,4 @@ +1 +0 0 + +0 0 diff --git a/dbms/tests/queries/0_stateless/00152_totals_in_subquery.sql b/dbms/tests/queries/0_stateless/00152_totals_in_subquery.sql new file mode 100644 index 00000000000..0dbb589d059 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00152_totals_in_subquery.sql @@ -0,0 +1,2 @@ +SELECT count() FROM (SELECT dummy, sum(dummy) GROUP BY dummy WITH TOTALS); +SELECT * FROM (SELECT dummy, sum(dummy) GROUP BY dummy WITH TOTALS);