1 | #include <AggregateFunctions/AggregateFunctionCategoricalInformationValue.h> |
---|---|
2 | |
3 | #include <AggregateFunctions/AggregateFunctionFactory.h> |
4 | #include <AggregateFunctions/FactoryHelpers.h> |
5 | #include <AggregateFunctions/Helpers.h> |
6 | #include "registerAggregateFunctions.h" |
7 | |
8 | |
9 | namespace DB |
10 | { |
11 | |
12 | namespace ErrorCodes |
13 | { |
14 | extern const int ILLEGAL_TYPE_OF_ARGUMENT; |
15 | extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; |
16 | } |
17 | |
18 | namespace |
19 | { |
20 | |
21 | AggregateFunctionPtr createAggregateFunctionCategoricalIV( |
22 | const std::string & name, |
23 | const DataTypes & arguments, |
24 | const Array & params |
25 | ) |
26 | { |
27 | assertNoParameters(name, params); |
28 | |
29 | if (arguments.size() < 2) |
30 | throw Exception( |
31 | "Aggregate function "+ name + " requires two or more arguments", |
32 | ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); |
33 | |
34 | for (auto & argument : arguments) |
35 | { |
36 | if (!WhichDataType(argument).isUInt8()) |
37 | throw Exception( |
38 | "All the arguments of aggregate function "+ name + " should be UInt8", |
39 | ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); |
40 | } |
41 | |
42 | return std::make_shared<AggregateFunctionCategoricalIV<>>(arguments, params); |
43 | } |
44 | |
45 | } |
46 | |
47 | void registerAggregateFunctionCategoricalIV( |
48 | AggregateFunctionFactory & factory |
49 | ) |
50 | { |
51 | factory.registerFunction("categoricalInformationValue", createAggregateFunctionCategoricalIV); |
52 | } |
53 | |
54 | } |
55 |