From 4eccd81e9420af0ce6c1812e531f3a518494c43e Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 16 Aug 2022 14:39:03 +0800 Subject: [PATCH] fix:error in tag filter optimization --- source/libs/executor/src/executil.c | 4 +++- tests/system-test/2-query/json_tag.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 2a43751707..2e82ab3d89 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -433,8 +433,10 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray tagVal.cid = pColInfo->info.colId; const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal); - if (p == NULL){ + if (p == NULL || (pColInfo->info.type == TSDB_DATA_TYPE_JSON && ((STag*)p)->nTag == 0)){ colDataAppend(pColInfo, i, p, true); + } else if (pColInfo->info.type == TSDB_DATA_TYPE_JSON) { + colDataAppend(pColInfo, i, p, false); } else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) { char *tmp = taosMemoryMalloc(tagVal.nData + VARSTR_HEADER_SIZE); varDataSetLen(tmp, tagVal.nData); diff --git a/tests/system-test/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index d9d7ef2300..30179062f5 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -216,7 +216,7 @@ class TDTestCase: # test where with json tag tdSql.query("select * from jsons1_1 where jtag is not null") - tdSql.query("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'") + tdSql.error("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'") tdSql.error("select * from jsons1 where jtag->'tag1'={}") # test json error