| 1 | #include <AggregateFunctions/AggregateFunctionOrFill.h> |
|---|---|
| 2 | |
| 3 | #include <AggregateFunctions/AggregateFunctionCombinatorFactory.h> |
| 4 | #include "registerAggregateFunctions.h" |
| 5 | |
| 6 | |
| 7 | namespace DB |
| 8 | { |
| 9 | |
| 10 | template <bool UseNull> |
| 11 | class AggregateFunctionCombinatorOrFill final : public IAggregateFunctionCombinator |
| 12 | { |
| 13 | public: |
| 14 | String getName() const override |
| 15 | { |
| 16 | if constexpr (UseNull) |
| 17 | return "OrNull"; |
| 18 | else |
| 19 | return "OrDefault"; |
| 20 | } |
| 21 | |
| 22 | AggregateFunctionPtr transformAggregateFunction( |
| 23 | const AggregateFunctionPtr & nested_function, |
| 24 | const DataTypes & arguments, |
| 25 | const Array & params) const override |
| 26 | { |
| 27 | return std::make_shared<AggregateFunctionOrFill<UseNull>>( |
| 28 | nested_function, |
| 29 | arguments, |
| 30 | params); |
| 31 | } |
| 32 | }; |
| 33 | |
| 34 | void registerAggregateFunctionCombinatorOrFill(AggregateFunctionCombinatorFactory & factory) |
| 35 | { |
| 36 | factory.registerCombinator(std::make_shared<AggregateFunctionCombinatorOrFill<false>>()); |
| 37 | factory.registerCombinator(std::make_shared<AggregateFunctionCombinatorOrFill<true>>()); |
| 38 | } |
| 39 | |
| 40 | } |
| 41 |