From aa80aa39bcfa818cd70302e5716c7ad2bc053638 Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Thu, 12 Sep 2024 15:34:57 +0800 Subject: [PATCH] fix(query):use window start key when ts column is null --- include/libs/function/functionMgt.h | 1 + source/libs/executor/src/timewindowoperator.c | 10 ++++++++-- source/libs/function/src/functionMgt.c | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 233e201ac3..519207377b 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -280,6 +280,7 @@ bool fmIsSkipScanCheckFunc(int32_t funcId); bool fmIsPrimaryKeyFunc(int32_t funcId); bool fmIsProcessByRowFunc(int32_t funcId); bool fmisSelectGroupConstValueFunc(int32_t funcId); +bool fmIsElapsedFunc(int32_t funcId); void getLastCacheDataType(SDataType* pType, int32_t pkBytes); int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc); diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 640ce5c98b..0cd506d15a 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -293,7 +293,9 @@ void doTimeWindowInterpolation(SArray* pPrevValues, SArray* pDataBlock, TSKEY pr SPoint point2 = (SPoint){.key = curTs, .val = &v2}; SPoint point = (SPoint){.key = windowKey, .val = &v}; - taosGetLinearInterpolationVal(&point, TSDB_DATA_TYPE_DOUBLE, &point1, &point2, TSDB_DATA_TYPE_DOUBLE); + if (!fmIsElapsedFunc(pCtx[k].functionId)) { + taosGetLinearInterpolationVal(&point, TSDB_DATA_TYPE_DOUBLE, &point1, &point2, TSDB_DATA_TYPE_DOUBLE); + } if (type == RESULT_ROW_START_INTERP) { pCtx[k].start.key = point.key; @@ -639,7 +641,11 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num int64_t prevTs = *(int64_t*)pTsKey->pData; if (groupId == pBlock->info.id.groupId) { - doTimeWindowInterpolation(pInfo->pPrevValues, pBlock->pDataBlock, prevTs, -1, tsCols[startPos], startPos, w.ekey, + TSKEY curTs = pBlock->info.window.skey; + if (tsCols != NULL) { + curTs = tsCols[startPos]; + } + doTimeWindowInterpolation(pInfo->pPrevValues, pBlock->pDataBlock, prevTs, -1, curTs, startPos, w.ekey, RESULT_ROW_END_INTERP, pSup); } diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 1a927a1576..886772b36c 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -276,6 +276,13 @@ bool fmisSelectGroupConstValueFunc(int32_t funcId) { return FUNCTION_TYPE_GROUP_CONST_VALUE == funcMgtBuiltins[funcId].type; } +bool fmIsElapsedFunc(int32_t funcId) { + if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { + return false; + } + return FUNCTION_TYPE_ELAPSED == funcMgtBuiltins[funcId].type; +} + bool fmIsBlockDistFunc(int32_t funcId) { if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { return false;