From 7691b97226aabceafdc7e801baec48d834eb082f Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Tue, 17 May 2022 21:15:26 +0800 Subject: [PATCH] fix(query): fill check currentKey validate when set input data --- src/query/src/qFill.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c index fad3b50c6c..f828f454de 100644 --- a/src/query/src/qFill.c +++ b/src/query/src/qFill.c @@ -451,6 +451,27 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput) memcpy(pTag->tagVal, pColData->pData, pCol->col.bytes); // TODO not memcpy?? } } + + // check currentKey validate + if (!FILL_IS_ASC_FILL(pFillInfo)) { + int64_t* tsList = (int64_t*) pFillInfo->pData[0]; + int32_t numOfRows = taosNumOfRemainRows(pFillInfo); + int64_t numOfRes = -1; + if (numOfRows > 0) { + TSKEY lastKey = tsList[pFillInfo->numOfRows - 1]; + numOfRes = taosTimeCountInterval( + lastKey, + pFillInfo->currentKey, + pFillInfo->interval.sliding, + pFillInfo->interval.slidingUnit, + pFillInfo->precision); + numOfRes += 1; + if(numOfRes < numOfRows) { + // reset current Key + pFillInfo->currentKey = tsList[0]; + } + } + } } bool taosFillHasMoreResults(SFillInfo* pFillInfo) { -- GitLab