From 0cef3bf31ca8995b675ee860eb08da9e5ad17f3e Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 29 Nov 2018 13:31:12 -0600 Subject: [PATCH] MCOL-1983 Have regr_intercept, regr_slope and regr_r2 return NULL for 1 or 0 rows in set --- utils/regr/regr_intercept.cpp | 2 +- utils/regr/regr_r2.cpp | 2 +- utils/regr/regr_slope.cpp | 2 +- utils/windowfunction/wf_udaf.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/regr/regr_intercept.cpp b/utils/regr/regr_intercept.cpp index 6d4c35a47..011488d9d 100644 --- a/utils/regr/regr_intercept.cpp +++ b/utils/regr/regr_intercept.cpp @@ -139,7 +139,7 @@ mcsv1_UDAF::ReturnCode regr_intercept::evaluate(mcsv1Context* context, static_an { struct regr_intercept_data* data = (struct regr_intercept_data*)context->getUserData()->data; double N = data->cnt; - if (N > 0) + if (N > 1) { double sumx = data->sumx; double sumy = data->sumy; diff --git a/utils/regr/regr_r2.cpp b/utils/regr/regr_r2.cpp index 34e8888e8..96b0ada18 100644 --- a/utils/regr/regr_r2.cpp +++ b/utils/regr/regr_r2.cpp @@ -144,7 +144,7 @@ mcsv1_UDAF::ReturnCode regr_r2::evaluate(mcsv1Context* context, static_any::any& { struct regr_r2_data* data = (struct regr_r2_data*)context->getUserData()->data; double N = data->cnt; - if (N > 0) + if (N > 1) { double sumx = data->sumx; double sumy = data->sumy; diff --git a/utils/regr/regr_slope.cpp b/utils/regr/regr_slope.cpp index da178673a..fdb94795a 100644 --- a/utils/regr/regr_slope.cpp +++ b/utils/regr/regr_slope.cpp @@ -139,7 +139,7 @@ mcsv1_UDAF::ReturnCode regr_slope::evaluate(mcsv1Context* context, static_any::a { struct regr_slope_data* data = (struct regr_slope_data*)context->getUserData()->data; double N = data->cnt; - if (N > 0) + if (N > 1) { // COVAR_POP(y, x) / VAR_POP(x) double sumx = data->sumx; diff --git a/utils/windowfunction/wf_udaf.cpp b/utils/windowfunction/wf_udaf.cpp index 2b7e28abc..5986c2872 100644 --- a/utils/windowfunction/wf_udaf.cpp +++ b/utils/windowfunction/wf_udaf.cpp @@ -84,7 +84,6 @@ void WF_udaf::resetData() getContext().getFunction()->reset(&getContext()); fDistinctMap.clear(); WindowFunctionType::resetData(); - fValOut.reset(); } void WF_udaf::parseParms(const std::vector& parms) @@ -709,6 +708,7 @@ void WF_udaf::operator()(int64_t b, int64_t e, int64_t c) mcsv1sdk::mcsv1_UDAF::ReturnCode rc; uint64_t colOut = fFieldIndex[0]; bool isNull = false; + fValOut.reset(); if ((fFrameUnit == WF__FRAME_ROWS) || (fPrev == -1) ||