From a2101df25a6a0fba99aa71f8793d762af2b801ee Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 27 Jul 2018 22:51:13 +0300 Subject: [PATCH] Fixed error in aggregate function "anyHeavy"; added a test [#CLICKHOUSE-3867] --- dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h | 2 +- .../queries/0_stateless/00677_shard_any_heavy_merge.reference | 1 + dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.sql | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.reference create mode 100644 dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.sql diff --git a/dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h b/dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h index 4b92a6231fe..322307c2bcf 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionMinMaxAny.h @@ -646,7 +646,7 @@ struct AggregateFunctionAnyHeavyData : Data } else { - if (counter < to.counter) + if ((!this->has() && to.has()) || counter < to.counter) { this->change(to, arena); return true; diff --git a/dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.reference b/dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.reference new file mode 100644 index 00000000000..ec20747d6cd --- /dev/null +++ b/dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.reference @@ -0,0 +1 @@ +4 ['hello','world'] hello diff --git a/dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.sql b/dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.sql new file mode 100644 index 00000000000..f6fac23a155 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00677_shard_any_heavy_merge.sql @@ -0,0 +1 @@ +WITH arrayJoin(['hello', 'world']) AS s SELECT count(), arraySort(groupUniqArray(s)), anyHeavy(s) FROM remote('127.0.0.{2,3}', system.one);