Merge pull request #22060 from taosdata/fix/TD-25209
fix: reset interpolation buffer after last valid row for interval + fill(next)
This commit is contained in:
commit
1a19d29eee
|
@ -247,7 +247,7 @@ static void initBeforeAfterDataBuf(SFillInfo* pFillInfo) {
|
|||
|
||||
static void saveColData(SArray* rowBuf, int32_t columnIndex, const char* src, bool isNull);
|
||||
|
||||
static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SRowVal* pRowVal) {
|
||||
static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SRowVal* pRowVal, bool reset) {
|
||||
SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->srcTsSlotId);
|
||||
pRowVal->key = ((int64_t*)pTsCol->pData)[rowIndex];
|
||||
|
||||
|
@ -268,7 +268,7 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SRowVa
|
|||
bool isNull = colDataIsNull_s(pSrcCol, rowIndex);
|
||||
char* p = colDataGetData(pSrcCol, rowIndex);
|
||||
|
||||
saveColData(pRowVal->pRowVal, i, p, isNull);
|
||||
saveColData(pRowVal->pRowVal, i, p, reset ? true : isNull);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -293,10 +293,10 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
|||
// set the next value for interpolation
|
||||
if (pFillInfo->currentKey < ts && ascFill) {
|
||||
SRowVal* pRVal = pFillInfo->type == TSDB_FILL_NEXT ? &pFillInfo->next : &pFillInfo->prev;
|
||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pRVal);
|
||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pRVal, false);
|
||||
} else if (pFillInfo->currentKey > ts && !ascFill) {
|
||||
SRowVal* pRVal = pFillInfo->type == TSDB_FILL_NEXT ? &pFillInfo->prev : &pFillInfo->next;
|
||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pRVal);
|
||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pRVal, false);
|
||||
}
|
||||
|
||||
if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) &&
|
||||
|
@ -316,9 +316,14 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
|||
ASSERT(pFillInfo->currentKey == ts);
|
||||
int32_t index = pBlock->info.rows;
|
||||
|
||||
if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) {
|
||||
if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||
int32_t nextRowIndex = pFillInfo->index + 1;
|
||||
copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, &pFillInfo->next);
|
||||
if ((pFillInfo->index + 1) < pFillInfo->numOfRows) {
|
||||
copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, &pFillInfo->next, false);
|
||||
} else {
|
||||
// reset to null after last row
|
||||
copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, &pFillInfo->next, true);
|
||||
}
|
||||
}
|
||||
|
||||
// copy rows to dst buffer
|
||||
|
|
|
@ -1143,4 +1143,85 @@ if $rows != 20026 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
print ===================== TD-25209 test fill prev/next/linear after data range
|
||||
sql use $db
|
||||
|
||||
sql select _wstart,_wend,count(*) from tm0 where ts >= '2020-01-01 01:03:06.000' and ts <= '2020-01-01 01:03:10.000' interval(1s) fill(prev);
|
||||
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data22 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data32 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data42 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstart,_wend,count(*) from tm0 where ts >= '2020-01-01 01:03:06.000' and ts <= '2020-01-01 01:03:10.000' interval(1s) fill(next);
|
||||
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data22 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data32 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data42 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstart,_wend,count(*) from tm0 where ts >= '2020-01-01 01:03:06.000' and ts <= '2020-01-01 01:03:10.000' interval(1s) fill(linear);
|
||||
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data22 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data32 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data42 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
Loading…
Reference in New Issue