Fix one more UB

This commit is contained in:
Alexey Milovidov 2022-12-11 04:29:06 +01:00
parent 9cb095554f
commit 0acadc6724
2 changed files with 6 additions and 0 deletions

View File

@ -55,6 +55,9 @@ struct QuantileReservoirSampler
/// Get the value of the `level` quantile. The level must be between 0 and 1.
Value get(Float64 level)
{
if (data.empty())
return {};
if constexpr (is_decimal<Value>)
return Value(static_cast<typename Value::NativeType>(data.quantileInterpolated(level)));
else

View File

@ -55,6 +55,9 @@ struct QuantileReservoirSamplerDeterministic
/// Get the value of the `level` quantile. The level must be between 0 and 1.
Value get(Float64 level)
{
if (data.empty())
return {};
if constexpr (is_decimal<Value>)
return static_cast<typename Value::NativeType>(data.quantileInterpolated(level));
else