From 92408ddaabdb2a524833176a61aa85f712a9a078 Mon Sep 17 00:00:00 2001 From: xywang Date: Thu, 19 May 2022 22:42:45 +0800 Subject: [PATCH] feat(query): fixed bit-op error when left operand was a logic-op --- src/common/src/texpr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index d824a60a17..2852b4eea1 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -252,15 +252,21 @@ int32_t exprTreeValidateExprNode(tExprNode *pExpr) { } } - // colx bitwise_op (coly logic_op n) + // colx logic_op n bitwise_op coly + if (pLeft->resultType == TSDB_DATA_TYPE_DOUBLE) { + pLeft->resultType = TSDB_DATA_TYPE_BIGINT; + pLeft->resultBytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + } + + // colx bitwise_op coly logic_op n if (pRight->resultType == TSDB_DATA_TYPE_DOUBLE) { pRight->resultType = TSDB_DATA_TYPE_BIGINT; pRight->resultBytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; } if (pExpr->_node.optr == TSDB_BINARY_OP_LSHIFT || pExpr->_node.optr == TSDB_BINARY_OP_RSHIFT) { - pExpr->resultType = leftType; - pExpr->resultBytes = tDataTypes[leftType].bytes; + pExpr->resultType = pLeft->resultType; + pExpr->resultBytes = tDataTypes[pLeft->resultType].bytes; } else { pExpr->resultType = TSDB_DATA_TYPE_BIGINT; pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; -- GitLab