1 | #pragma once |
2 | |
3 | #include <DataTypes/DataTypeCustom.h> |
4 | #include <AggregateFunctions/IAggregateFunction.h> |
5 | #include <Common/FieldVisitors.h> |
6 | |
7 | #include <IO/ReadHelpers.h> |
8 | |
9 | namespace DB |
10 | { |
11 | |
12 | /** The type SimpleAggregateFunction(fct, type) is meant to be used in an AggregatingMergeTree. It behaves like a standard |
13 | * data type but when rows are merged, an aggregation function is applied. |
14 | * |
15 | * The aggregation function is limited to simple functions whose merge state is the final result: |
16 | * any, anyLast, min, max, sum |
17 | * |
18 | * Examples: |
19 | * |
20 | * SimpleAggregateFunction(sum, Nullable(Float64)) |
21 | * SimpleAggregateFunction(anyLast, LowCardinality(Nullable(String))) |
22 | * SimpleAggregateFunction(anyLast, IPv4) |
23 | * |
24 | * Technically, a standard IDataType is instanciated and customized with IDataTypeCustomName and DataTypeCustomDesc. |
25 | */ |
26 | |
27 | class DataTypeCustomSimpleAggregateFunction : public IDataTypeCustomName |
28 | { |
29 | private: |
30 | const AggregateFunctionPtr function; |
31 | const DataTypes argument_types; |
32 | const Array parameters; |
33 | |
34 | public: |
35 | DataTypeCustomSimpleAggregateFunction(const AggregateFunctionPtr & function_, const DataTypes & argument_types_, const Array & parameters_) |
36 | : function(function_), argument_types(argument_types_), parameters(parameters_) {} |
37 | |
38 | const AggregateFunctionPtr getFunction() const { return function; } |
39 | String getName() const override; |
40 | }; |
41 | |
42 | } |
43 | |