unexpected behaviour for avg over empty decimal column without group by

This commit is contained in:
akonyaev 2019-10-17 16:08:04 +03:00
parent e595df05d9
commit 22429a699e

View File

@ -27,12 +27,8 @@ struct AggregateFunctionAvgData
template <typename ResultT>
ResultT NO_SANITIZE_UNDEFINED result() const
{
if constexpr (std::is_floating_point_v<ResultT>)
if constexpr (std::numeric_limits<ResultT>::is_iec559)
return static_cast<ResultT>(sum) / count; /// allow division by zero
if (!count)
throw Exception("AggregateFunctionAvg with zero values", ErrorCodes::LOGICAL_ERROR);
if (count == 0)
return 0;
return static_cast<ResultT>(sum) / count;
}
};