From d4eb8c7352bc3ae732e1177f6d5afc8350408303 Mon Sep 17 00:00:00 2001 From: Bhavna Jindal Date: Tue, 28 Nov 2023 10:06:40 -0800 Subject: [PATCH] handled NaN and inf values --- src/Functions/seriesDecomposeSTL.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Functions/seriesDecomposeSTL.cpp b/src/Functions/seriesDecomposeSTL.cpp index 0c05d22a5ae..7a9937e2b35 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 @@ public: 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 @@ public: 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;