1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-1793 Window functions return garbage if current row outside of window frame.

This commit is contained in:
David Hall
2018-11-06 10:11:45 -06:00
parent 826fdc82d5
commit d01fe36fdc
3 changed files with 14 additions and 5 deletions

View File

@ -205,6 +205,7 @@
<F N="allnull.cpp"/> <F N="allnull.cpp"/>
<F N="avg_mode.cpp"/> <F N="avg_mode.cpp"/>
<F N="avgx.cpp"/> <F N="avgx.cpp"/>
<F N="distinct_count.cpp"/>
<F N="mcsv1_udaf.cpp"/> <F N="mcsv1_udaf.cpp"/>
<F N="median.cpp"/> <F N="median.cpp"/>
<F N="ssq.cpp"/> <F N="ssq.cpp"/>
@ -217,6 +218,7 @@
<F N="allnull.h"/> <F N="allnull.h"/>
<F N="avg_mode.h"/> <F N="avg_mode.h"/>
<F N="avgx.h"/> <F N="avgx.h"/>
<F N="distinct_count.h"/>
<F N="mcsv1_udaf.h"/> <F N="mcsv1_udaf.h"/>
<F N="median.h"/> <F N="median.h"/>
<F N="ssq.h"/> <F N="ssq.h"/>

View File

@ -481,6 +481,7 @@ bool WF_udaf::dropValues(int64_t b, int64_t e)
} }
} }
WindowFunctionType::resetData();
return true; return true;
} }
@ -708,6 +709,12 @@ void WF_udaf::operator()(int64_t b, int64_t e, int64_t c)
uint64_t colOut = fFieldIndex[0]; uint64_t colOut = fFieldIndex[0];
bool isNull = false; bool isNull = false;
// Initialize result to NULL. If no values are found, NULL is the result.
// if (getContext().getRunFlag(mcsv1sdk::UDAF_DEFAULT_NULL))
// {
// getNullValueAny(fValOut, getContext().getResultType(), getContext().getColWidth());
// }
if ((fFrameUnit == WF__FRAME_ROWS) || if ((fFrameUnit == WF__FRAME_ROWS) ||
(fPrev == -1) || (fPrev == -1) ||
(!fPeer->operator()(getPointer(fRowData->at(c)), getPointer(fRowData->at(fPrev))))) (!fPeer->operator()(getPointer(fRowData->at(c)), getPointer(fRowData->at(fPrev)))))

View File

@ -188,7 +188,7 @@ void WindowFunction::operator()()
} }
// If b > e then the frame is entirely outside of the partition // If b > e then the frame is entirely outside of the partition
// and there's no values to add // and there's no values to drop
if (b <= e) if (b <= e)
{ {
// UDAnF functions may have a dropValue function implemented. // UDAnF functions may have a dropValue function implemented.
@ -207,15 +207,15 @@ void WindowFunction::operator()()
} }
else else
{ {
// dropValues failed so do the entire frame. // dropValues failed or doesn't exist
// so do the entire frame.
fFunctionType->resetData(); fFunctionType->resetData();
} }
} }
fFunctionType->operator()(b, e, i); // Calls nextValue
} }
prevFrame = w; fFunctionType->operator()(b, e, i); // UDAnF: Calls nextValue and evaluate
firstTime = false; firstTime = false;
prevFrame = w;
} }
} }
} }