Fix various sum*() functions via remote() usage (incorrect function name)

This commit is contained in:
Azat Khuzhin 2020-03-12 22:13:38 +03:00
parent 7f8b2b0c41
commit 9e999e0fb9
4 changed files with 29 additions and 8 deletions

View File

@ -21,7 +21,7 @@ struct SumSimple
/// @note It uses slow Decimal128 (cause we need such a variant). sumWithOverflow is faster for Decimal32/64
using ResultType = std::conditional_t<IsDecimalNumber<T>, Decimal128, NearestFieldType<T>>;
using AggregateDataType = AggregateFunctionSumData<ResultType>;
using Function = AggregateFunctionSum<T, ResultType, AggregateDataType>;
using Function = AggregateFunctionSum<T, ResultType, AggregateDataType, AggregateFunctionTypeSum>;
};
template <typename T>
@ -29,7 +29,7 @@ struct SumSameType
{
using ResultType = T;
using AggregateDataType = AggregateFunctionSumData<ResultType>;
using Function = AggregateFunctionSum<T, ResultType, AggregateDataType>;
using Function = AggregateFunctionSum<T, ResultType, AggregateDataType, AggregateFunctionTypeSumWithOverflow>;
};
template <typename T>
@ -37,7 +37,7 @@ struct SumKahan
{
using ResultType = Float64;
using AggregateDataType = AggregateFunctionSumKahanData<ResultType>;
using Function = AggregateFunctionSum<T, ResultType, AggregateDataType>;
using Function = AggregateFunctionSum<T, ResultType, AggregateDataType, AggregateFunctionTypeSumKahan>;
};
template <typename T> using AggregateFunctionSumSimple = typename SumSimple<T>::Function;

View File

@ -91,24 +91,39 @@ struct AggregateFunctionSumKahanData
};
enum AggregateFunctionSumType
{
AggregateFunctionTypeSum,
AggregateFunctionTypeSumWithOverflow,
AggregateFunctionTypeSumKahan,
};
/// Counts the sum of the numbers.
template <typename T, typename TResult, typename Data>
class AggregateFunctionSum final : public IAggregateFunctionDataHelper<Data, AggregateFunctionSum<T, TResult, Data>>
template <typename T, typename TResult, typename Data, AggregateFunctionSumType Type>
class AggregateFunctionSum final : public IAggregateFunctionDataHelper<Data, AggregateFunctionSum<T, TResult, Data, Type>>
{
public:
using ResultDataType = std::conditional_t<IsDecimalNumber<T>, DataTypeDecimal<TResult>, DataTypeNumber<TResult>>;
using ColVecType = std::conditional_t<IsDecimalNumber<T>, ColumnDecimal<T>, ColumnVector<T>>;
using ColVecResult = std::conditional_t<IsDecimalNumber<T>, ColumnDecimal<TResult>, ColumnVector<TResult>>;
String getName() const override { return "sum"; }
String getName() const override
{
if constexpr (Type == AggregateFunctionTypeSum)
return "sum";
else if constexpr (Type == AggregateFunctionTypeSumWithOverflow)
return "sumWithOverflow";
else if constexpr (Type == AggregateFunctionTypeSumKahan)
return "sumKahan";
__builtin_unreachable();
}
AggregateFunctionSum(const DataTypes & argument_types_)
: IAggregateFunctionDataHelper<Data, AggregateFunctionSum<T, TResult, Data>>(argument_types_, {})
: IAggregateFunctionDataHelper<Data, AggregateFunctionSum<T, TResult, Data, Type>>(argument_types_, {})
, scale(0)
{}
AggregateFunctionSum(const IDataType & data_type, const DataTypes & argument_types_)
: IAggregateFunctionDataHelper<Data, AggregateFunctionSum<T, TResult, Data>>(argument_types_, {})
: IAggregateFunctionDataHelper<Data, AggregateFunctionSum<T, TResult, Data, Type>>(argument_types_, {})
, scale(getDecimalScale(data_type))
{}

View File

@ -0,0 +1,3 @@
0
0
0

View File

@ -0,0 +1,3 @@
select sumKahan(dummy) from remote('127.{2,3}', system.one);
select sumWithOverflow(dummy) from remote('127.{2,3}', system.one);
select sum(dummy) from remote('127.{2,3}', system.one);