You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-1793 Refactor to handle another edge case. Also fix CORR and reset
This commit is contained in:
@ -144,7 +144,7 @@ mcsv1_UDAF::ReturnCode corr::evaluate(mcsv1Context* context, static_any::any& va
|
||||
{
|
||||
struct corr_data* data = (struct corr_data*)context->getUserData()->data;
|
||||
double N = data->cnt;
|
||||
if (N > 0)
|
||||
if (N > 1)
|
||||
{
|
||||
double sumx = data->sumx;
|
||||
double sumy = data->sumy;
|
||||
@ -161,8 +161,7 @@ mcsv1_UDAF::ReturnCode corr::evaluate(mcsv1Context* context, static_any::any& va
|
||||
double var_popy = (sumy2 - (sumy * sumy / N)) / N;
|
||||
if (var_popy == 0)
|
||||
{
|
||||
// When var_popy is 0, 1 is the result
|
||||
valOut = 1.0;
|
||||
// When var_popy is 0, NULL is the result
|
||||
return mcsv1_UDAF::SUCCESS;
|
||||
}
|
||||
double std_popx = sqrt(var_popx);
|
||||
|
@ -84,6 +84,7 @@ void WF_udaf::resetData()
|
||||
getContext().getFunction()->reset(&getContext());
|
||||
fDistinctMap.clear();
|
||||
WindowFunctionType::resetData();
|
||||
fValOut.reset();
|
||||
}
|
||||
|
||||
void WF_udaf::parseParms(const std::vector<execplan::SRCP>& parms)
|
||||
@ -708,7 +709,6 @@ 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) ||
|
||||
|
@ -194,11 +194,7 @@ void WindowFunction::operator()()
|
||||
// Built-in functions may have this functionality added in the future.
|
||||
// If b > e then the frame is entirely outside of the partition
|
||||
// and there's no values to drop
|
||||
if (b <= e)
|
||||
{
|
||||
if (!firstTime)
|
||||
{
|
||||
if (fFunctionType->dropValues(prevFrame.first, w.first))
|
||||
if (!firstTime && (b <= e) && fFunctionType->dropValues(prevFrame.first, w.first))
|
||||
{
|
||||
// Adjust the beginning of the frame for nextValue
|
||||
// to start where the previous frame left off.
|
||||
@ -206,19 +202,13 @@ void WindowFunction::operator()()
|
||||
}
|
||||
else
|
||||
{
|
||||
// dropValues failed or doesn't exist
|
||||
// so calculate the entire frame.
|
||||
// If dropValues failed or doesn't exist,
|
||||
// calculate the entire frame.
|
||||
fFunctionType->resetData();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fFunctionType->resetData();
|
||||
firstTime = false;
|
||||
}
|
||||
}
|
||||
fFunctionType->operator()(b, e, i); // UDAnF: Calls nextValue and evaluate
|
||||
prevFrame = w;
|
||||
firstTime = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user