You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
MCOL-4516 check for var_pop < 0
In some cases, because of rounding error, var_pop will evaluate to some value just less than 0. We check for this and force to round to 0.
This commit is contained in:
@ -128,8 +128,10 @@ mcsv1_UDAF::ReturnCode regr_sxx::evaluate(mcsv1Context* context, static_any::any
|
||||
long double N = data->cnt;
|
||||
if (N > 0)
|
||||
{
|
||||
long double var_popx = (data->sumx2 - (data->sumx * data->sumx / N));
|
||||
valOut = static_cast<double>(var_popx);
|
||||
long double regr_sxx = (data->sumx2 - (data->sumx * data->sumx / N));
|
||||
if (regr_sxx < 0) // catch -0
|
||||
regr_sxx = 0;
|
||||
valOut = static_cast<double>(regr_sxx);
|
||||
}
|
||||
return mcsv1_UDAF::SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user