From e9fa1accf12eea3b4ec3da3f0a7fe98aa1a59005 Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Fri, 9 Dec 2022 17:32:28 +0100 Subject: [PATCH] fix another bug in AggregateFunctionMinMaxAny --- src/AggregateFunctions/AggregateFunctionMinMaxAny.h | 3 +++ .../0_stateless/02431_single_value_or_null_empty.reference | 1 + tests/queries/0_stateless/02431_single_value_or_null_empty.sql | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/AggregateFunctions/AggregateFunctionMinMaxAny.h b/src/AggregateFunctions/AggregateFunctionMinMaxAny.h index 8117daa4760..a6013f37b9d 100644 --- a/src/AggregateFunctions/AggregateFunctionMinMaxAny.h +++ b/src/AggregateFunctions/AggregateFunctionMinMaxAny.h @@ -1163,6 +1163,9 @@ struct AggregateFunctionAnyHeavyData : Data bool changeIfBetter(const Self & to, Arena * arena) { + if (!to.has()) + return false; + if (this->isEqualTo(to)) { counter += to.counter; diff --git a/tests/queries/0_stateless/02431_single_value_or_null_empty.reference b/tests/queries/0_stateless/02431_single_value_or_null_empty.reference index 50d25a40af1..e66cf303e63 100644 --- a/tests/queries/0_stateless/02431_single_value_or_null_empty.reference +++ b/tests/queries/0_stateless/02431_single_value_or_null_empty.reference @@ -3,3 +3,4 @@ \N 0 \N \N \N 0 \N \N \N +1 diff --git a/tests/queries/0_stateless/02431_single_value_or_null_empty.sql b/tests/queries/0_stateless/02431_single_value_or_null_empty.sql index 50d7e1a4a8d..e213ecc7abb 100644 --- a/tests/queries/0_stateless/02431_single_value_or_null_empty.sql +++ b/tests/queries/0_stateless/02431_single_value_or_null_empty.sql @@ -31,3 +31,5 @@ FROM numbers(0) ) GROUP BY NULL WITH CUBE; + +SELECT anyHeavy('1') FROM (SELECT anyHeavy(1));