From 2f3536bacd3f545d4417284db0ead37082922000 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sat, 8 Oct 2022 18:28:09 +0800 Subject: [PATCH 1/3] fix(query): fix infinite interpolation results generated when sliding window is smaller than interval window in descending time order --- source/libs/executor/src/tfill.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 27b8e83a20..10a65065fc 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -583,8 +583,8 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma numOfRes += 1; assert(numOfRes >= numOfRows); } else { // reach the end of data - if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) || - (ekey1 > pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) { + if ((ekey1 <= pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) || + (ekey1 >= pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) { return 0; } numOfRes = taosTimeCountInterval(ekey1, pFillInfo->currentKey, pFillInfo->interval.sliding, From e9f30db0ab64b2d150e2d97a2da5f9ed7929bef1 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sat, 8 Oct 2022 18:28:09 +0800 Subject: [PATCH 2/3] fix(query): fix infinite interpolation results generated when sliding window is smaller than interval window in descending time order --- source/libs/executor/src/tfill.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 10a65065fc..34997a5dd8 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -583,7 +583,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma numOfRes += 1; assert(numOfRes >= numOfRows); } else { // reach the end of data - if ((ekey1 <= pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) || + if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) || (ekey1 >= pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) { return 0; } From 1fc1546af9459dc5745698d62b4c3867016f1efa Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sat, 8 Oct 2022 19:22:49 +0800 Subject: [PATCH 3/3] add test case for desc fill --- tests/script/tsim/parser/fill.sim | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/script/tsim/parser/fill.sim b/tests/script/tsim/parser/fill.sim index 4892345e12..ea0311ebde 100644 --- a/tests/script/tsim/parser/fill.sim +++ b/tests/script/tsim/parser/fill.sim @@ -795,12 +795,34 @@ if $data81 != 4 then endi # desc fill query -print desc fill query -sql select count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10); +print asc fill query +sql select _wstart,count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10) order by _wstart asc; if $rows != 12 then return -1 endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +print desc fill query +sql select _wstart,count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10) order by _wstart desc; +if $rows != 12 then + return -1 +endi + +if $data00 != @18-09-17 09:11:00.000@ then + return -1 +endi + +if $data01 != 10 then + return -1 +endi + print =====================> aggregation + arithmetic + fill, need to add cases TODO #sql select avg(cpu_taosd) - first(cpu_taosd) from dn1 where ts<'2020-11-13 11:00:00' and ts>'2020-11-13 10:50:00' interval(10s) fill(value, 99) #sql select count(*), first(k), avg(k), avg(k)-first(k) from tm0 where ts>'2020-1-1 1:1:1' and ts<'2020-1-1 1:02:59' interval(10s) fill(value, 99);