From c39f3c87a20e77e79899a31cc60b1fa79dd24db9 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 24 Sep 2021 11:04:34 +0800 Subject: [PATCH] TD-6129 add tag-> select logic --- src/client/src/tscSQLParser.c | 4 +--- src/client/src/tscUtil.c | 7 +++---- src/query/src/qExecutor.c | 1 - 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 3a02eb3ef2..7c2f8e8958 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1862,7 +1862,6 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn assert(right != NULL && right->type == SQL_NODE_VALUE); tVariantAssign(&(pExpr->base.param[pExpr->base.numOfParams]), &right->value); pExpr->base.numOfParams++; - pExpr->base.resType = TSDB_DATA_TYPE_BINARY; // tag-> operation transform result type assert(pExpr->base.numOfParams <= 3); } @@ -2264,8 +2263,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t pToken = &left->columnName; tSqlExpr* right = pItem->pNode->pRight; - assert(right != NULL && right->type == SQL_NODE_VALUE); - if(right->tokenId != TK_STRING){ + if(right != NULL || right->type != SQL_NODE_VALUE || right->tokenId != TK_STRING){ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); } }else { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 33ca4ed2ea..db8f0de85c 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -5187,20 +5187,19 @@ void findTagValue(void* data, char* key, int32_t keyLen, char* out, int16_t len) void* result = kvRowColVal(data, pColIdx); if (k % 2 != 0) { // json key - char tagJsonKey[TSDB_MAX_TAGS_LEN] = {0}; if (JSON_TYPE_BINARY){ if (keyLen != varDataLen(result)) continue; if (memcmp(varDataVal(result), key, keyLen) != 0) continue; } else if(JSON_TYPE_NCHAR){ + char tagJsonKey[TSDB_MAX_TAGS_LEN] = {0}; int32_t length = taosUcs4ToMbs(varDataVal(result), varDataLen(result), tagJsonKey); if (length == 0) { tscError("charset:%s to %s. val:%s convert json key failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)result); continue; } - if (strncmp(key, tagJsonKey, keyLen) != 0) { - continue; - } + if (keyLen != length) continue; + if (strncmp(key, tagJsonKey, keyLen) != 0) continue; } found = true; } else { // json value diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index ea576a6e33..5c12936fd2 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -7185,7 +7185,6 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { dst = pColInfo->pData + count * pExprInfo[j].base.resBytes; if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) { data = tsdbGetTableName(item->pTable); - } else { data = tsdbGetTableTagVal(item->pTable, pExprInfo[j].base.colInfo.colId, type, bytes); if(type == TSDB_DATA_TYPE_JSON){ -- GitLab