From e7aabfe43c70cb9872013f1420a50804642bf691 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 30 Oct 2015 05:29:53 +0300 Subject: [PATCH] dbms: fixed error [#MTRSADMIN-1690]. --- dbms/src/Interpreters/Aggregator.cpp | 6 +++++- .../00263_merge_aggregates_and_overflow.reference | 1 + .../00263_merge_aggregates_and_overflow.sql | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00263_merge_aggregates_and_overflow.reference create mode 100644 dbms/tests/queries/0_stateless/00263_merge_aggregates_and_overflow.sql diff --git a/dbms/src/Interpreters/Aggregator.cpp b/dbms/src/Interpreters/Aggregator.cpp index bb7bff6f616..096f1c92151 100644 --- a/dbms/src/Interpreters/Aggregator.cpp +++ b/dbms/src/Interpreters/Aggregator.cpp @@ -1356,11 +1356,15 @@ void NO_INLINE Aggregator::mergeSingleLevelDataImpl( mergeDataImpl( getDataVariant(*res).data, getDataVariant(current).data); - else + else if (res->without_key) mergeDataNoMoreKeysImpl( getDataVariant(*res).data, res->without_key, getDataVariant(current).data); + else + mergeDataOnlyExistingKeysImpl( + getDataVariant(*res).data, + getDataVariant(current).data); /// current не будет уничтожать состояния агрегатных функций в деструкторе current.aggregator = nullptr; diff --git a/dbms/tests/queries/0_stateless/00263_merge_aggregates_and_overflow.reference b/dbms/tests/queries/0_stateless/00263_merge_aggregates_and_overflow.reference new file mode 100644 index 00000000000..d05b1f927f4 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00263_merge_aggregates_and_overflow.reference @@ -0,0 +1 @@ +0 0 diff --git a/dbms/tests/queries/0_stateless/00263_merge_aggregates_and_overflow.sql b/dbms/tests/queries/0_stateless/00263_merge_aggregates_and_overflow.sql new file mode 100644 index 00000000000..604d89cca1d --- /dev/null +++ b/dbms/tests/queries/0_stateless/00263_merge_aggregates_and_overflow.sql @@ -0,0 +1,12 @@ +DROP TABLE IF EXISTS test.numbers_10k_log; + +SET max_block_size = 1000; + +CREATE TABLE test.numbers_10k_log ENGINE = Log AS SELECT number FROM system.numbers LIMIT 10000; + +SET max_threads = 4; +SET max_rows_to_group_by = 3000, group_by_overflow_mode = 'any'; + +SELECT ignore(rand() AS k), ignore(max(toString(number))) FROM test.numbers_10k_log GROUP BY k LIMIT 1; + +DROP TABLE test.numbers_10k_log;