uniqCombined should return non-nullable type

Signed-off-by: Duc Canh Le <duccanh.le@ahrefs.com>
This commit is contained in:
Duc Canh Le 2024-06-11 10:42:26 +00:00
parent 1f68f5246d
commit fd947374b5
3 changed files with 26 additions and 10 deletions

View File

@ -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});
}
}

View File

@ -1,2 +1,4 @@
10021957
10021969
1
1

View File

@ -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;