#include #include #include #include #include "registerAggregateFunctions.h" namespace DB { namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; } namespace { template struct SumSimple { /// @note It uses slow Decimal128 (cause we need such a variant). sumWithOverflow is faster for Decimal32/64 using ResultType = std::conditional_t, std::conditional_t, Decimal256, Decimal128>, NearestFieldType>; // using ResultType = std::conditional_t, Decimal128, NearestFieldType>; using AggregateDataType = AggregateFunctionSumData; using Function = AggregateFunctionSum; }; template struct SumSameType { using ResultType = T; using AggregateDataType = AggregateFunctionSumData; using Function = AggregateFunctionSum; }; template struct SumKahan { using ResultType = Float64; using AggregateDataType = AggregateFunctionSumKahanData; using Function = AggregateFunctionSum; }; template using AggregateFunctionSumSimple = typename SumSimple::Function; template using AggregateFunctionSumWithOverflow = typename SumSameType::Function; template using AggregateFunctionSumKahan = std::conditional_t, typename SumSimple::Function, typename SumKahan::Function>; template