From dc92b279137461bc1f6083d13c9f09f8736496cf Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 19 Jul 2022 20:32:55 +0800 Subject: [PATCH] fix(query): fix the timewindow calculate error. --- source/libs/executor/src/executil.c | 26 +++----------------------- source/libs/executor/src/tfill.c | 5 +++-- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 4c86a46b6c..978bef1607 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -842,30 +842,10 @@ static void getInitialStartTimeWindow(SInterval* pInterval, TSKEY ts, STimeWindo } static STimeWindow doCalculateTimeWindow(int64_t ts, SInterval* pInterval) { - STimeWindow w = {0}; - - if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') { - w.skey = taosTimeTruncate(ts, pInterval, pInterval->precision); - w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; - } else { - int64_t st = w.skey; - if (pInterval->offset > 0) { - st = taosTimeAdd(st, pInterval->offset, pInterval->offsetUnit, pInterval->precision); - } - - if (st > ts) { - st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; - } - - int64_t et = st + pInterval->interval - 1; - if (et < ts) { - st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; - } - - w.skey = st; - w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; - } + STimeWindow w = {0}; + w.skey = taosTimeTruncate(ts, pInterval, pInterval->precision); + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; return w; } diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 550938140e..31c079e55f 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -544,8 +544,9 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) { return true; } - if (pFillInfo->numOfTotal > 0 && (((pFillInfo->end > pFillInfo->start) && FILL_IS_ASC_FILL(pFillInfo)) || - (pFillInfo->end < pFillInfo->start && !FILL_IS_ASC_FILL(pFillInfo)))) { + bool ascFill = FILL_IS_ASC_FILL(pFillInfo); + if (pFillInfo->numOfTotal > 0 && + (((pFillInfo->end > pFillInfo->start) && ascFill) || (pFillInfo->end < pFillInfo->start && !ascFill))) { return getNumOfResultsAfterFillGap(pFillInfo, pFillInfo->end, 4096) > 0; } -- GitLab