ClickHouse
43 строки · 1.3 Кб
1#include <AggregateFunctions/AggregateFunctionFactory.h>2#include <AggregateFunctions/AggregateFunctionCount.h>3#include <AggregateFunctions/FactoryHelpers.h>4
5
6namespace DB7{
8
9namespace ErrorCodes10{
11extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;12}
13
14struct Settings;15
16AggregateFunctionPtr AggregateFunctionCount::getOwnNullAdapter(17const AggregateFunctionPtr &, const DataTypes & types, const Array & params, const AggregateFunctionProperties & /*properties*/) const18{
19return std::make_shared<AggregateFunctionCountNotNullUnary>(types[0], params);20}
21
22namespace
23{
24
25AggregateFunctionPtr createAggregateFunctionCount(const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings *)26{
27assertNoParameters(name, parameters);28
29if (argument_types.size() > 1)30throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Aggregate function {} requires zero or one argument", name);31
32return std::make_shared<AggregateFunctionCount>(argument_types);33}
34
35}
36
37void registerAggregateFunctionCount(AggregateFunctionFactory & factory)38{
39AggregateFunctionProperties properties = { .returns_default_when_only_null = true, .is_order_dependent = false };40factory.registerFunction("count", {createAggregateFunctionCount, properties}, AggregateFunctionFactory::CaseInsensitive);41}
42
43}
44