2018-08-16 03:11:35 +00:00
|
|
|
#include <AggregateFunctions/AggregateFunctionFactory.h>
|
|
|
|
#include <AggregateFunctions/AggregateFunctionRetention.h>
|
|
|
|
#include <AggregateFunctions/Helpers.h>
|
|
|
|
#include <AggregateFunctions/FactoryHelpers.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-05-26 11:32:14 +00:00
|
|
|
struct Settings;
|
|
|
|
|
2020-02-25 18:10:48 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
|
|
|
}
|
2018-08-16 03:11:35 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2021-05-26 11:32:14 +00:00
|
|
|
AggregateFunctionPtr createAggregateFunctionRetention(const std::string & name, const DataTypes & arguments, const Array & params, const Settings *)
|
2018-08-16 03:11:35 +00:00
|
|
|
{
|
|
|
|
assertNoParameters(name, params);
|
|
|
|
|
2018-08-23 00:49:18 +00:00
|
|
|
if (arguments.size() < 2)
|
|
|
|
throw Exception("Not enough event arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
|
|
|
|
|
|
|
if (arguments.size() > AggregateFunctionRetentionData::max_events)
|
2018-08-16 03:11:35 +00:00
|
|
|
throw Exception("Too many event arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
|
|
|
|
|
|
|
return std::make_shared<AggregateFunctionRetention>(arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void registerAggregateFunctionRetention(AggregateFunctionFactory & factory)
|
|
|
|
{
|
2020-10-26 19:20:40 +00:00
|
|
|
factory.registerFunction("retention", createAggregateFunctionRetention);
|
2018-08-16 03:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|