From f6ca617feb424acc1539788e50072ae807d731e6 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 2 Dec 2024 21:30:28 +0800 Subject: [PATCH] fix:[TS-5712] calculate ts error in vectorMathTsSubHelper --- source/libs/scalar/src/sclvector.c | 2 +- tests/parallel_test/cases.task | 1 + tests/system-test/2-query/ts-5712.py | 45 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/system-test/2-query/ts-5712.py diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 8db0562c63..c6c8333392 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -1377,7 +1377,7 @@ static int32_t vectorMathTsSubHelper(SColumnInfoData *pLeftCol, SColumnInfoData SCL_ERR_RET(getVectorBigintValueFnLeft(pLeftCol->pData, i, &leftRes)); SCL_ERR_RET(getVectorBigintValueFnRight(pRightCol->pData, 0, &rightRes)); *output = - taosTimeAdd(leftRes, -rightRes, pRightCol->info.scale, pRightCol->info.precision); + taosTimeAdd(leftRes, -rightRes, pRightCol->info.scale, pRightCol->info.precision) * factor; } } SCL_RET(TSDB_CODE_SUCCESS); diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 34ff38eb43..879d93ab3a 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -209,6 +209,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-5712.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py -Q 3 diff --git a/tests/system-test/2-query/ts-5712.py b/tests/system-test/2-query/ts-5712.py new file mode 100644 index 0000000000..a2cfa61d4a --- /dev/null +++ b/tests/system-test/2-query/ts-5712.py @@ -0,0 +1,45 @@ + +import taos + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + self.dbname = 'db' + self.stbname = 'st' + + def prepareData(self): + # db + tdSql.execute(f"create database db;") + tdSql.execute(f"use db") + + # super table + tdSql.execute("CREATE TABLE t1( time TIMESTAMP, c1 BIGINT);") + + # create index for all tags + tdSql.execute("INSERT INTO t1(time, c1) VALUES (1641024000000, 0)") + tdSql.execute("INSERT INTO t1(time, c1) VALUES (1641024000001, 0)") + + def check(self): + tdSql.query(f"SELECT CAST(time AS BIGINT) FROM t1 WHERE (1 - time) > 0") + tdSql.checkRows(0) + + def run(self): + self.prepareData() + self.check() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase())