diff --git a/src/Functions/seriesDecomposeSTL.cpp b/src/Functions/seriesDecomposeSTL.cpp index 0c05d22a5ae0..7a9937e2b355 100644 --- a/src/Functions/seriesDecomposeSTL.cpp +++ b/src/Functions/seriesDecomposeSTL.cpp @@ -23,6 +23,8 @@ #include #include #include +#include + namespace DB { @@ -77,7 +79,8 @@ class FunctionSeriesDecomposeSTL : public IFunction period = period_ptr->getUInt(0); else if (checkAndGetColumn(period_ptr.get()) || checkAndGetColumn(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 @@ class FunctionSeriesDecomposeSTL : public IFunction try { - auto res = stl::params().fit(src, static_cast(period)); + auto res = stl::params().fit(src, static_cast(std::round(period))); if (res.seasonal.empty()) return false;