Fix tests

This commit is contained in:
Alexey Milovidov 2020-06-17 03:08:01 +03:00
parent 634829bccb
commit e720d78f23
2 changed files with 9 additions and 6 deletions

View File

@ -77,11 +77,15 @@ AggregateFunctionPtr AggregateFunctionFactory::get(
DataTypes nested_types = combinator->transformArguments(type_without_low_cardinality); DataTypes nested_types = combinator->transformArguments(type_without_low_cardinality);
Array nested_parameters = combinator->transformParameters(parameters); Array nested_parameters = combinator->transformParameters(parameters);
AggregateFunctionPtr nested_function = getImpl(name, nested_types, nested_parameters, out_properties, recursion_level); bool has_null_arguments = std::any_of(type_without_low_cardinality.begin(), type_without_low_cardinality.end(),
[](const auto & type) { return type->onlyNull(); });
AggregateFunctionPtr nested_function = getImpl(
name, nested_types, nested_parameters, out_properties, has_null_arguments, recursion_level);
return combinator->transformAggregateFunction(nested_function, out_properties, type_without_low_cardinality, parameters); return combinator->transformAggregateFunction(nested_function, out_properties, type_without_low_cardinality, parameters);
} }
auto res = getImpl(name, type_without_low_cardinality, parameters, out_properties, recursion_level); auto res = getImpl(name, type_without_low_cardinality, parameters, out_properties, false, recursion_level);
if (!res) if (!res)
throw Exception("Logical error: AggregateFunctionFactory returned nullptr", ErrorCodes::LOGICAL_ERROR); throw Exception("Logical error: AggregateFunctionFactory returned nullptr", ErrorCodes::LOGICAL_ERROR);
return res; return res;
@ -93,6 +97,7 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl(
const DataTypes & argument_types, const DataTypes & argument_types,
const Array & parameters, const Array & parameters,
AggregateFunctionProperties & out_properties, AggregateFunctionProperties & out_properties,
bool has_null_arguments,
int recursion_level) const int recursion_level) const
{ {
String name = getAliasToOrName(name_param); String name = getAliasToOrName(name_param);
@ -116,11 +121,8 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl(
out_properties = found.properties; out_properties = found.properties;
/// The case when aggregate function should return NULL on NULL arguments. This case is handled in "get" method. /// The case when aggregate function should return NULL on NULL arguments. This case is handled in "get" method.
if (!out_properties.returns_default_when_only_null if (!out_properties.returns_default_when_only_null && has_null_arguments)
&& std::any_of(argument_types.begin(), argument_types.end(), [](const auto & type) { return WhichDataType(type).isNothing(); }))
{
return nullptr; return nullptr;
}
return found.creator(name, argument_types, parameters); return found.creator(name, argument_types, parameters);
} }

View File

@ -79,6 +79,7 @@ private:
const DataTypes & argument_types, const DataTypes & argument_types,
const Array & parameters, const Array & parameters,
AggregateFunctionProperties & out_properties, AggregateFunctionProperties & out_properties,
bool has_null_arguments,
int recursion_level) const; int recursion_level) const;
private: private: