diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index d8622d93ee..fa03f4ccd1 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -4848,6 +4848,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) { } SColumnNode *refNode = (SColumnNode *)node->pLeft; + int32_t type = refNode->node.resType.type; SExprNode *exprNode = NULL; if (OP_TYPE_IN != node->opType) { SValueNode *valueNode = (SValueNode *)node->pRight; @@ -4856,6 +4857,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) { valueNode->node.resType.type = TSDB_DATA_TYPE_BIGINT; } exprNode = &valueNode->node; + type = vectorGetConvertType(refNode->node.resType.type, exprNode->resType.type); } else { SNodeListNode *listNode = (SNodeListNode *)node->pRight; if (LIST_LENGTH(listNode->pNodeList) > 10) { @@ -4863,8 +4865,19 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) { return DEAL_RES_CONTINUE; } exprNode = &listNode->node; + SListCell *cell = listNode->pNodeList->pHead; + for (int32_t i = 0; i < listNode->pNodeList->length; ++i) { + SValueNode *valueNode = (SValueNode *)cell->pNode; + cell = cell->pNext; + if (IS_NUMERIC_TYPE(valueNode->node.resType.type) && IS_NUMERIC_TYPE(type)) { + int32_t tmp = vectorGetConvertType(type, valueNode->node.resType.type); + if (tmp != 0){ + type = tmp; + } + } + } + exprNode->resType.type = type; } - int32_t type = vectorGetConvertType(refNode->node.resType.type, exprNode->resType.type); if (0 != type && type != refNode->node.resType.type) { stat->scalarMode = true; return DEAL_RES_CONTINUE; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 347bb3c7cd..b3610d035f 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -1718,9 +1718,6 @@ 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/system-test/2-query/ts-5761-scalemode.py b/tests/system-test/2-query/ts-5761-scalemode.py index 24eafc6cc7..b47a43588e 100644 --- a/tests/system-test/2-query/ts-5761-scalemode.py +++ b/tests/system-test/2-query/ts-5761-scalemode.py @@ -1,4 +1,3 @@ - import taos from util.log import * @@ -22,21 +21,26 @@ class TDTestCase: 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);") + tdSql.execute("CREATE TABLE t1( time TIMESTAMP, c1 BIGINT, c2 smallint, c3 double, c4 int UNSIGNED, c5 bool, c6 binary(32), c7 nchar(32));") # create index for all tags - tdSql.execute("INSERT INTO t1 VALUES (1641024000000, 1, 1, 1, 1, 1)") + tdSql.execute("INSERT INTO t1 VALUES (1641024000000, 1, 1, 1, 1, 1, '1', '1')") def check(self): - tdSql.query(f"SELECT * FROM t1 WHERE c1 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c1 in (1.7, 2)") tdSql.checkRows(0) - tdSql.query(f"SELECT * FROM t1 WHERE c2 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c2 in (1.7, 2)") tdSql.checkRows(0) - tdSql.query(f"SELECT * FROM t1 WHERE c3 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c3 in (1.7, 2)") tdSql.checkRows(0) - tdSql.query(f"SELECT * FROM t1 WHERE c4 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c4 in (1.7, 2)") tdSql.checkRows(0) - tdSql.query(f"SELECT * FROM t1 WHERE c5 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c5 in (1.7, 2)") + tdSql.checkRows(1) + + tdSql.query(f"SELECT * FROM t1 WHERE c6 in (1.7, 2)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c7 in (1, 2)") tdSql.checkRows(1) def run(self): @@ -50,4 +54,4 @@ class TDTestCase: tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/2-query/ts-5761.py b/tests/system-test/2-query/ts-5761.py index 565d2753d0..c833661c76 100644 --- a/tests/system-test/2-query/ts-5761.py +++ b/tests/system-test/2-query/ts-5761.py @@ -1,4 +1,3 @@ - import taos from util.log import * @@ -21,21 +20,26 @@ class TDTestCase: 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);") + tdSql.execute("CREATE TABLE t1( time TIMESTAMP, c1 BIGINT, c2 smallint, c3 double, c4 int UNSIGNED, c5 bool, c6 binary(32), c7 nchar(32));") # create index for all tags - tdSql.execute("INSERT INTO t1 VALUES (1641024000000, 1, 1, 1, 1, 1)") + tdSql.execute("INSERT INTO t1 VALUES (1641024000000, 1, 1, 1, 1, 1, '1', '1')") def check(self): - tdSql.query(f"SELECT * FROM t1 WHERE c1 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c1 in (1.7, 2)") tdSql.checkRows(0) - tdSql.query(f"SELECT * FROM t1 WHERE c2 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c2 in (1.7, 2)") tdSql.checkRows(0) - tdSql.query(f"SELECT * FROM t1 WHERE c3 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c3 in (1.7, 2)") tdSql.checkRows(0) - tdSql.query(f"SELECT * FROM t1 WHERE c4 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c4 in (1.7, 2)") tdSql.checkRows(0) - tdSql.query(f"SELECT * FROM t1 WHERE c5 in (1.7)") + tdSql.query(f"SELECT * FROM t1 WHERE c5 in (1.7, 2)") + tdSql.checkRows(1) + + tdSql.query(f"SELECT * FROM t1 WHERE c6 in (1.7, 2)") + tdSql.checkRows(0) + tdSql.query(f"SELECT * FROM t1 WHERE c7 in (1, 2)") tdSql.checkRows(1) def run(self): @@ -49,4 +53,4 @@ class TDTestCase: tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file