未验证 提交 6a537681 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #12586 from taosdata/fix/TD-14782-V24

fix(query): V24 Fill function with order by desc
...@@ -69,7 +69,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData ...@@ -69,7 +69,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData
// set the other values // set the other values
if (pFillInfo->type == TSDB_FILL_PREV) { if (pFillInfo->type == TSDB_FILL_PREV) {
char* p = FILL_IS_ASC_FILL(pFillInfo) ? prev : next; char* p = prev;
if (p != NULL) { if (p != NULL) {
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) { for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
...@@ -85,7 +85,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData ...@@ -85,7 +85,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index); setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index);
} }
} else if (pFillInfo->type == TSDB_FILL_NEXT) { } else if (pFillInfo->type == TSDB_FILL_NEXT) {
char* p = FILL_IS_ASC_FILL(pFillInfo)? next : prev; char* p = next;
if (p != NULL) { if (p != NULL) {
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) { for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
...@@ -178,8 +178,6 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, void** data, int32_t outputR ...@@ -178,8 +178,6 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, void** data, int32_t outputR
if (FILL_IS_ASC_FILL(pFillInfo)) { if (FILL_IS_ASC_FILL(pFillInfo)) {
assert(pFillInfo->currentKey >= pFillInfo->start); assert(pFillInfo->currentKey >= pFillInfo->start);
} else {
assert(pFillInfo->currentKey <= pFillInfo->start);
} }
while (pFillInfo->numOfCurrent < outputRows) { while (pFillInfo->numOfCurrent < outputRows) {
...@@ -451,6 +449,27 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput) ...@@ -451,6 +449,27 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput)
memcpy(pTag->tagVal, pColData->pData, pCol->col.bytes); // TODO not memcpy?? 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) { bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
...@@ -459,8 +478,7 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) { ...@@ -459,8 +478,7 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
return true; return true;
} }
if (pFillInfo->numOfTotal > 0 && (((pFillInfo->end > pFillInfo->start) && FILL_IS_ASC_FILL(pFillInfo)) || if (pFillInfo->numOfTotal > 0 && pFillInfo->end > pFillInfo->start) {
(pFillInfo->end < pFillInfo->start && !FILL_IS_ASC_FILL(pFillInfo)))) {
return getNumOfResultsAfterFillGap(pFillInfo, pFillInfo->end, 4096) > 0; return getNumOfResultsAfterFillGap(pFillInfo, pFillInfo->end, 4096) > 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册