From eac27fc0fd1454aa057b8e82a61c6a6f46b13f1e Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 24 Feb 2023 18:39:17 +0800 Subject: [PATCH 1/4] fix: empty ts range query issue --- source/libs/parser/src/parTranslater.c | 3 +++ tests/parallel_test/cases.task | 1 + tests/script/tsim/query/emptyTsRange.sim | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 tests/script/tsim/query/emptyTsRange.sim diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 7b6f795ecf..7e9ca9554b 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3342,6 +3342,9 @@ static int32_t translateWhere(STranslateContext* pCxt, SSelectStmt* pSelect) { if (TSDB_CODE_SUCCESS == code) { code = getQueryTimeRange(pCxt, pSelect->pWhere, &pSelect->timeRange); } + if (TSDB_CODE_SUCCESS == code && pSelect->timeRange.skey > pSelect->timeRange.ekey) { + pSelect->isEmptyResult = true; + } return code; } diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 63760d6ae4..867f16d71a 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -181,6 +181,7 @@ ,,y,script,./test.sh -f tsim/query/groupby.sim ,,y,script,./test.sh -f tsim/query/event.sim ,,y,script,./test.sh -f tsim/query/forceFill.sim +,,y,script,./test.sh -f tsim/query/emptyTsRange.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim ,,y,script,./test.sh -f tsim/mnode/basic1.sim diff --git a/tests/script/tsim/query/emptyTsRange.sim b/tests/script/tsim/query/emptyTsRange.sim new file mode 100644 index 0000000000..ca3daf2bbb --- /dev/null +++ b/tests/script/tsim/query/emptyTsRange.sim @@ -0,0 +1,20 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql drop database if exists db1; +sql create database if not exists db1; +sql use db1; +sql create stable sta (ts timestamp, f1 double, f2 binary(200)) tags(t1 int); +sql create table tba1 using sta tags(1); +sql insert into tba1 values ('2022-04-26 15:15:01', 1.0, "a"); +sql insert into tba1 values ('2022-04-26 15:15:02', 2.0, "b"); +sql insert into tba1 values ('2022-04-26 15:15:04', 4.0, "b"); +sql insert into tba1 values ('2022-04-26 15:15:05', 5.0, "b"); +sql select last_row(*) from sta where ts >= 1678901803783 and ts <= 1678901803783 and _c0 <= 1678901803782 interval(10d,8d) fill(linear) order by _wstart desc; +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT From e2cb423120c2276262aaee38ede06afa8f4ed9c3 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 25 Feb 2023 16:13:36 +0800 Subject: [PATCH 2/4] fix:add timeout time --- Jenkinsfile2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 9c28489a39..23bba6739b 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -387,7 +387,7 @@ pipeline { } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 75, unit: 'MINUTES'){ + timeout(time: 86, unit: 'MINUTES'){ pre_test_win() pre_test_build_win() run_win_ctest() @@ -423,7 +423,7 @@ pipeline { echo "${WKDIR}/restore.sh -p ${BRANCH_NAME} -n ${BUILD_ID} -c {container name}" } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 120, unit: 'MINUTES'){ + timeout(time: 130, unit: 'MINUTES'){ pre_test() script { sh ''' From 2aa41b76a49dc7b373b5859ea20fbbf9043bb6c6 Mon Sep 17 00:00:00 2001 From: dapan1121 <72057773+dapan1121@users.noreply.github.com> Date: Sun, 26 Feb 2023 07:59:26 +0800 Subject: [PATCH 3/4] Update cases.task --- tests/parallel_test/cases.task | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index e3cca56129..9412d61ec7 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -182,7 +182,6 @@ ,,y,script,./test.sh -f tsim/query/event.sim ,,y,script,./test.sh -f tsim/query/forceFill.sim ,,y,script,./test.sh -f tsim/query/emptyTsRange.sim -,,y,script,./test.sh -f tsim/query/join.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim ,,y,script,./test.sh -f tsim/mnode/basic1.sim From 622896f5247266bf5c6f9884018bd05a1be1a999 Mon Sep 17 00:00:00 2001 From: dapan1121 <72057773+dapan1121@users.noreply.github.com> Date: Sun, 26 Feb 2023 17:50:35 +0800 Subject: [PATCH 4/4] Update Jenkinsfile2 --- Jenkinsfile2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 23bba6739b..916437b914 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -387,7 +387,7 @@ pipeline { } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 86, unit: 'MINUTES'){ + timeout(time: 126, unit: 'MINUTES'){ pre_test_win() pre_test_build_win() run_win_ctest()