diff --git a/src/AggregateFunctions/AggregateFunctionUniqCombined.cpp b/src/AggregateFunctions/AggregateFunctionUniqCombined.cpp index 89e0a77f45c..5224ae1a406 100644 --- a/src/AggregateFunctions/AggregateFunctionUniqCombined.cpp +++ b/src/AggregateFunctions/AggregateFunctionUniqCombined.cpp @@ -65,16 +65,17 @@ AggregateFunctionPtr createAggregateFunctionUniqCombined(bool use_64_bit_hash, void registerAggregateFunctionUniqCombined(AggregateFunctionFactory & factory) { - factory.registerFunction("uniqCombined", - [](const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings *) - { - return createAggregateFunctionUniqCombined(false, name, argument_types, parameters); - }); - factory.registerFunction("uniqCombined64", - [](const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings *) - { - return createAggregateFunctionUniqCombined(true, name, argument_types, parameters); - }); + AggregateFunctionProperties properties = {.returns_default_when_only_null = true, .is_order_dependent = false}; + factory.registerFunction( + "uniqCombined", + {[](const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings *) + { return createAggregateFunctionUniqCombined(false, name, argument_types, parameters); }, + properties}); + factory.registerFunction( + "uniqCombined64", + {[](const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings *) + { return createAggregateFunctionUniqCombined(true, name, argument_types, parameters); }, + properties}); } } diff --git a/tests/queries/0_stateless/01016_uniqCombined64.reference b/tests/queries/0_stateless/01016_uniqCombined64.reference index 050969af80d..f9964b92ff4 100644 --- a/tests/queries/0_stateless/01016_uniqCombined64.reference +++ b/tests/queries/0_stateless/01016_uniqCombined64.reference @@ -1,2 +1,4 @@ 10021957 10021969 +1 +1 diff --git a/tests/queries/0_stateless/01016_uniqCombined64.sql b/tests/queries/0_stateless/01016_uniqCombined64.sql index acf8135760a..b6fd240ac7f 100644 --- a/tests/queries/0_stateless/01016_uniqCombined64.sql +++ b/tests/queries/0_stateless/01016_uniqCombined64.sql @@ -7,3 +7,16 @@ SELECT uniqCombined(number) FROM numbers(1e7); SELECT uniqCombined64(number) FROM numbers(1e7); + +-- Fix for https://github.com/ClickHouse/ClickHouse/issues/65052 +SELECT sum(u) FROM +( + SELECT uniqCombined(tuple(materialize(toNullable(42)))) AS u +) +SETTINGS optimize_injective_functions_inside_uniq = 1, allow_experimental_analyzer = 1; + +SELECT sum(u) FROM +( + SELECT uniqCombined64(tuple(materialize(toNullable(42)))) AS u +) +SETTINGS optimize_injective_functions_inside_uniq = 1, allow_experimental_analyzer = 1;