Skip to content

Commit

Permalink
handled NaN and inf values
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavnajindal committed Nov 28, 2023
1 parent 6edd62d commit f585a73
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Functions/seriesDecomposeSTL.cpp
Expand Up @@ -23,6 +23,8 @@
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/IFunction.h>
#include <Common/NaNUtils.h>


namespace DB
{
Expand Down Expand Up @@ -77,7 +79,8 @@ class FunctionSeriesDecomposeSTL : public IFunction
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",
Expand Down Expand Up @@ -164,7 +167,7 @@ class FunctionSeriesDecomposeSTL : public IFunction

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;
Expand Down

0 comments on commit f585a73

Please sign in to comment.