mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Merge pull request #9636 from azat/fix-sum-remote
Fix various sum*() functions via remote() usage (incorrect function name)
This commit is contained in:
commit
3ef1d40b97
@ -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;
|
||||
|
@ -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))
|
||||
{}
|
||||
|
||||
|
3
dbms/tests/queries/0_stateless/01098_sum.reference
Normal file
3
dbms/tests/queries/0_stateless/01098_sum.reference
Normal file
@ -0,0 +1,3 @@
|
||||
0
|
||||
0
|
||||
0
|
3
dbms/tests/queries/0_stateless/01098_sum.sql
Normal file
3
dbms/tests/queries/0_stateless/01098_sum.sql
Normal 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);
|
Loading…
Reference in New Issue
Block a user