handled NaN and inf values

This commit is contained in:
Bhavna Jindal 2023-11-28 10:06:40 -08:00
parent c0cff7b4f3
commit d4eb8c7352

View File

@ -23,6 +23,8 @@
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/IFunction.h>
#include <Common/NaNUtils.h>
namespace DB
{
@ -77,7 +79,8 @@ public:
period = period_ptr->getUInt(0);
else if (checkAndGetColumn<ColumnFloat32>(period_ptr.get()) || checkAndGetColumn<ColumnFloat64>(period_ptr.get()))
{
if ((period = period_ptr->getFloat64(0)) < 0)
period = period_ptr->getFloat64(0);
if (isNaN(period) || !std::isfinite(period) || period < 0)
throw Exception(
ErrorCodes::ILLEGAL_COLUMN,
"Illegal value {} for second argument of function {}. Should be a positive number",
@ -164,7 +167,7 @@ public:
try
{
auto res = stl::params().fit(src, static_cast<size_t>(period));
auto res = stl::params().fit(src, static_cast<size_t>(std::round(period)));
if (res.seasonal.empty())
return false;