ClickHouse/dbms/src/AggregateFunctions/AggregateFunctionAvg.cpp

33 lines
921 B
C++
Raw Normal View History

#include <AggregateFunctions/AggregateFunctionFactory.h>
#include <AggregateFunctions/AggregateFunctionAvg.h>
#include <AggregateFunctions/Helpers.h>
#include <AggregateFunctions/FactoryHelpers.h>
2015-09-24 12:40:36 +00:00
namespace DB
{
namespace
{
AggregateFunctionPtr createAggregateFunctionAvg(const std::string & name, const DataTypes & argument_types, const Array & parameters)
2015-09-24 12:40:36 +00:00
{
assertNoParameters(name, parameters);
assertUnary(name, argument_types)
2015-09-24 12:40:36 +00:00
AggregateFunctionPtr res(createWithNumericType<AggregateFunctionAvg>(*argument_types[0]));
2015-09-24 12:40:36 +00:00
if (!res)
throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
2015-09-24 12:40:36 +00:00
return res;
2015-09-24 12:40:36 +00:00
}
}
void registerAggregateFunctionAvg(AggregateFunctionFactory & factory)
{
factory.registerFunction("avg", createAggregateFunctionAvg, AggregateFunctionFactory::CaseInsensitive);
2015-09-24 12:40:36 +00:00
}
}