From 990cda48df9fab8597945d5b98c6b4caa2665d61 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 30 Sep 2021 16:12:17 +0800 Subject: [PATCH] TD-6129 add tag?'key' in where logic --- src/query/src/qFilter.c | 3 ++- src/tsdb/src/tsdbRead.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/query/src/qFilter.c b/src/query/src/qFilter.c index 22b4d00a4c..90e063387a 100644 --- a/src/query/src/qFilter.c +++ b/src/query/src/qFilter.c @@ -1188,7 +1188,8 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g tExprNode* pLeft = tree->_node.pLeft; if(pLeft->nodeType == TSQL_NODE_EXPR && pLeft->_node.optr == TSDB_RELATION_ARROW){ // json tag -> operation assert(info->pTable != NULL); - void* data = getJsonTagValue(info->pTable, pLeft->_node.pLeft->pSchema->name, strlen(pLeft->_node.pLeft->pSchema->name)); + SSchema* schema = FILTER_GET_COL_FIELD_DESC(FILTER_GET_FIELD(info, left)); + void* data = getJsonTagValue(info->pTable, schema->name, strlen(schema->name)); if(data == NULL) return TSDB_CODE_QRY_JSON_KEY_NOT_EXIST; type = *(char*)data; assert(type > TSDB_DATA_TYPE_NULL && type < TSDB_DATA_TYPE_JSON); diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 4b625262dd..80b2bc52da 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -3783,17 +3783,18 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons void *filterInfo = calloc(1, sizeof(SFilterInfo)); ((SFilterInfo*)filterInfo)->pTable = pTable; ret = filterInitFromTree(expr, &filterInfo, 0); + tExprTreeDestroy(expr, NULL); + if (ret != TSDB_CODE_SUCCESS) { terrno = ret; tsdbUnlockRepoMeta(tsdb); + filterFreeInfo(filterInfo); goto _error; } tsdbQueryTableList(pTable, res, filterInfo); filterFreeInfo(filterInfo); - - tExprTreeDestroy(expr, NULL); pGroupInfo->numOfTables = (uint32_t)taosArrayGetSize(res); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); -- GitLab