From 1db40d873c4965c136816e9c910f53db285de36f Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 12 Dec 2024 14:36:44 +0800 Subject: [PATCH] fix:[TS-5761] error for in operator --- source/libs/scalar/src/scalar.c | 3 ++ tests/parallel_test/cases.task | 2 + .../system-test/2-query/ts-5761-scalemode.py | 53 +++++++++++++++++++ tests/system-test/2-query/ts-5761.py | 52 ++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 tests/system-test/2-query/ts-5761-scalemode.py create mode 100644 tests/system-test/2-query/ts-5761.py diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index b3610d035f..347bb3c7cd 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -1718,6 +1718,9 @@ static int32_t sclGetCompOperatorResType(SOperatorNode *pOp) { return TSDB_CODE_TSC_INVALID_OPERATION; } ((SExprNode *)(pOp->pRight))->resType = ldt; + if (IS_NUMERIC_TYPE(ldt.type)){ + ((SExprNode *)(pOp->pRight))->resType.type = TSDB_DATA_TYPE_DOUBLE; + } } else if (nodesIsRegularOp(pOp)) { if (pOp->pRight == NULL) { return TSDB_CODE_TSC_INVALID_OPERATION; diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 879d93ab3a..6ceb100169 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -209,6 +209,8 @@ ,,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-5761.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-5761-scalemode.py ,,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 diff --git a/tests/system-test/2-query/ts-5761-scalemode.py b/tests/system-test/2-query/ts-5761-scalemode.py new file mode 100644 index 0000000000..24eafc6cc7 --- /dev/null +++ b/tests/system-test/2-query/ts-5761-scalemode.py @@ -0,0 +1,53 @@ + +import taos + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * + +class TDTestCase: + updatecfgDict = {'filterScalarMode':1} + 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 tableUNSIGNED + tdSql.execute("CREATE TABLE t1( time TIMESTAMP, c1 BIGINT, c2 smallint, c3 double, c4 int UNSIGNED, c5 bool);") + + # create index for all tags + tdSql.execute("INSERT INTO t1 VALUES (1641024000000, 1, 1, 1, 1, 1)") + + def check(self): + tdSql.query(f"SELECT * FROM t1 WHERE c1 in (1.7)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c2 in (1.7)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c3 in (1.7)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c4 in (1.7)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c5 in (1.7)") + tdSql.checkRows(1) + + 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()) diff --git a/tests/system-test/2-query/ts-5761.py b/tests/system-test/2-query/ts-5761.py new file mode 100644 index 0000000000..565d2753d0 --- /dev/null +++ b/tests/system-test/2-query/ts-5761.py @@ -0,0 +1,52 @@ + +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 tableUNSIGNED + tdSql.execute("CREATE TABLE t1( time TIMESTAMP, c1 BIGINT, c2 smallint, c3 double, c4 int UNSIGNED, c5 bool);") + + # create index for all tags + tdSql.execute("INSERT INTO t1 VALUES (1641024000000, 1, 1, 1, 1, 1)") + + def check(self): + tdSql.query(f"SELECT * FROM t1 WHERE c1 in (1.7)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c2 in (1.7)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c3 in (1.7)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c4 in (1.7)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c5 in (1.7)") + tdSql.checkRows(1) + + 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())