From 507aa0c7f8b159fed9afd7858ebf3a7f0efb3ccd Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Thu, 17 Nov 2022 13:35:23 +0800 Subject: [PATCH] fix:fill operator core --- source/libs/executor/src/executorimpl.c | 3 +- source/libs/executor/src/timewindowoperator.c | 2 + tests/script/tsim/parser/fill.sim | 99 +++++++++++++++++++ 3 files changed, 102 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 39e876800f..cf890ac3d7 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1994,8 +1994,7 @@ static void doHandleRemainBlockForNewGroupImpl(SOperatorInfo* pOperator, SFillOp int32_t scanFlag = MAIN_SCAN; getTableScanInfo(pOperator, &order, &scanFlag); - int64_t ekey = - Q_STATUS_EQUAL(pTaskInfo->status, TASK_COMPLETED) ? pInfo->win.ekey : pInfo->existNewGroupBlock->info.window.ekey; + int64_t ekey = pInfo->existNewGroupBlock->info.window.ekey; taosResetFillInfo(pInfo->pFillInfo, getFillInfoStart(pInfo->pFillInfo)); blockDataCleanup(pInfo->pRes); diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 87b4ed4c4a..fe29b8eda9 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -4898,6 +4898,7 @@ static void doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { if (pMiaInfo->groupId == 0) { if (pMiaInfo->groupId != pBlock->info.groupId) { pMiaInfo->groupId = pBlock->info.groupId; + pRes->info.groupId = pMiaInfo->groupId; } } else { if (pMiaInfo->groupId != pBlock->info.groupId) { @@ -4911,6 +4912,7 @@ static void doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { break; } else { // continue + pRes->info.groupId = pMiaInfo->groupId; } } diff --git a/tests/script/tsim/parser/fill.sim b/tests/script/tsim/parser/fill.sim index ea0311ebde..463328a019 100644 --- a/tests/script/tsim/parser/fill.sim +++ b/tests/script/tsim/parser/fill.sim @@ -1049,4 +1049,103 @@ print =============== clear # return -1 #endi + +print ============== fill + +sql drop database if exists test; +sql create database test vgroups 4; +sql use test; +sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); +sql insert into t1 values(1648712211000,1,2,3); +sql insert into t1 values(1648712225000,2,2,3); +sql insert into t2 values(1648712212000,1,2,3); +sql insert into t2 values(1648712226000,2,2,3); + +$loop_count = 0 + +loop0: +sleep 200 + +sql select count(*) from(select count(a) from st where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(value, -1)); + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data00 != 20026 then + print =====data00=$data00 + goto loop0 +endi + +if $data10 != 20026 then + print =====data10=$data10 + goto loop0 +endi + +sql select _wstart, count(a) from st where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(prev); + +if $rows != 40052 then + print =====rows=$rows + return -1 +endi + +sql select _wstart, count(a) from st where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(next); + +if $rows != 40052 then + print =====rows=$rows + return -1 +endi + +sql select _wstart, count(a) from st where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(linear); + +if $rows != 40052 then + print =====rows=$rows + return -1 +endi + +sql select _wstart, count(a) from st where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(NULL); + +if $rows != 40052 then + print =====rows=$rows + return -1 +endi + +sql select _wstart, count(a) from t1 where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(value, -1); + +if $rows != 20026 then + print =====rows=$rows + return -1 +endi + +sql select _wstart, count(a) from t1 where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(NULL); + +if $rows != 20026 then + print =====rows=$rows + return -1 +endi + +sql select _wstart, count(a) from t1 where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(prev); + +if $rows != 20026 then + print =====rows=$rows + return -1 +endi + +sql select _wstart, count(a) from t1 where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(next); + +if $rows != 20026 then + print =====rows=$rows + return -1 +endi + +sql select _wstart, count(a) from t1 where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(linear); + +if $rows != 20026 then + print =====rows=$rows + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT -- GitLab