2017-04-01 09:19:00 +00:00
|
|
|
#include <AggregateFunctions/AggregateFunctionFactory.h>
|
|
|
|
#include <AggregateFunctions/HelpersMinMaxAny.h>
|
2017-12-20 07:36:30 +00:00
|
|
|
|
2015-09-24 12:40:36 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-05-26 11:32:14 +00:00
|
|
|
struct Settings;
|
2015-09-24 12:40:36 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2021-05-26 11:32:14 +00:00
|
|
|
AggregateFunctionPtr createAggregateFunctionAny(const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings * settings)
|
2015-09-24 12:40:36 +00:00
|
|
|
{
|
2021-05-26 11:32:14 +00:00
|
|
|
return AggregateFunctionPtr(createAggregateFunctionSingleValue<AggregateFunctionsSingleValue, AggregateFunctionAnyData>(name, argument_types, parameters, settings));
|
2015-09-24 12:40:36 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 11:32:14 +00:00
|
|
|
AggregateFunctionPtr createAggregateFunctionAnyLast(const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings * settings)
|
2015-09-24 12:40:36 +00:00
|
|
|
{
|
2021-05-26 11:32:14 +00:00
|
|
|
return AggregateFunctionPtr(createAggregateFunctionSingleValue<AggregateFunctionsSingleValue, AggregateFunctionAnyLastData>(name, argument_types, parameters, settings));
|
2015-09-24 12:40:36 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 11:32:14 +00:00
|
|
|
AggregateFunctionPtr createAggregateFunctionAnyHeavy(const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings * settings)
|
2016-06-26 12:48:04 +00:00
|
|
|
{
|
2021-05-26 11:32:14 +00:00
|
|
|
return AggregateFunctionPtr(createAggregateFunctionSingleValue<AggregateFunctionsSingleValue, AggregateFunctionAnyHeavyData>(name, argument_types, parameters, settings));
|
2016-06-26 12:48:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 12:40:36 +00:00
|
|
|
}
|
|
|
|
|
2020-12-21 05:51:11 +00:00
|
|
|
void registerAggregateFunctionsAny(AggregateFunctionFactory & factory)
|
2015-09-24 12:40:36 +00:00
|
|
|
{
|
2020-07-05 23:50:20 +00:00
|
|
|
AggregateFunctionProperties properties = { .returns_default_when_only_null = false, .is_order_dependent = true };
|
|
|
|
|
|
|
|
factory.registerFunction("any", { createAggregateFunctionAny, properties });
|
|
|
|
factory.registerFunction("anyLast", { createAggregateFunctionAnyLast, properties });
|
|
|
|
factory.registerFunction("anyHeavy", { createAggregateFunctionAnyHeavy, properties });
|
2021-02-11 15:41:54 +00:00
|
|
|
|
|
|
|
// Synonyms for use as window functions.
|
|
|
|
factory.registerFunction("first_value",
|
|
|
|
{ createAggregateFunctionAny, properties },
|
|
|
|
AggregateFunctionFactory::CaseInsensitive);
|
|
|
|
factory.registerFunction("last_value",
|
|
|
|
{ createAggregateFunctionAnyLast, properties },
|
|
|
|
AggregateFunctionFactory::CaseInsensitive);
|
2015-09-24 12:40:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|