1#include <AggregateFunctions/AggregateFunctionFactory.h>
2#include <AggregateFunctions/AggregateFunctionMaxIntersections.h>
3#include <AggregateFunctions/FactoryHelpers.h>
4#include <AggregateFunctions/Helpers.h>
5#include "registerAggregateFunctions.h"
6
7
8namespace DB
9{
10
11namespace
12{
13 AggregateFunctionPtr createAggregateFunctionMaxIntersections(
14 AggregateFunctionIntersectionsKind kind,
15 const std::string & name, const DataTypes & argument_types, const Array & parameters)
16 {
17 assertBinary(name, argument_types);
18 assertNoParameters(name, parameters);
19
20 AggregateFunctionPtr res(createWithNumericType<AggregateFunctionIntersectionsMax>(*argument_types[0], kind, argument_types));
21 if (!res)
22 throw Exception("Illegal types " + argument_types[0]->getName() + " and " + argument_types[1]->getName()
23 + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
24
25 return res;
26 }
27}
28
29void registerAggregateFunctionsMaxIntersections(AggregateFunctionFactory & factory)
30{
31 factory.registerFunction("maxIntersections", [](const std::string & name, const DataTypes & argument_types, const Array & parameters)
32 { return createAggregateFunctionMaxIntersections(AggregateFunctionIntersectionsKind::Count, name, argument_types, parameters); });
33
34 factory.registerFunction("maxIntersectionsPosition", [](const std::string & name, const DataTypes & argument_types, const Array & parameters)
35 { return createAggregateFunctionMaxIntersections(AggregateFunctionIntersectionsKind::Position, name, argument_types, parameters); });
36}
37
38}
39