From 4b19a9432887f87dad3099419b447e2194291aa3 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 24 Nov 2021 16:39:18 +0800 Subject: [PATCH] fix group by json tag format [change json type with qid return logic] --- src/client/src/tscSql.c | 2 +- src/client/src/tscUtil.c | 4 ++-- tests/pytest/stable/json_tag.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 37482389f8..672d385cc5 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -439,7 +439,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { if (pField->visible) { f[j] = pField->field; - if(f[j].type == TSDB_DATA_TYPE_JSON){ + if(f[j].type == TSDB_DATA_TYPE_JSON && pField->fieldJson.type != TSDB_DATA_TYPE_NULL){ f[j].type = pField->fieldJson.type; if(!IS_VAR_DATA_TYPE(f[j].type) && f[j].type != TSDB_DATA_TYPE_JSON){ f[j].bytes = pField->fieldJson.bytes; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 9bc0d459d7..8b6980e399 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2265,7 +2265,7 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) { assert(pFieldInfo != NULL); pFieldInfo->numOfOutput++; - struct SInternalField info = { .pExpr = NULL, .visible = true, .fieldJson={0} }; + struct SInternalField info = { .pExpr = NULL, .visible = true }; info.field = *pField; return taosArrayPush(pFieldInfo->internalField, &info); @@ -2273,7 +2273,7 @@ SInternalField* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) { SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* field) { pFieldInfo->numOfOutput++; - struct SInternalField info = { .pExpr = NULL, .visible = true, .fieldJson={0}}; + struct SInternalField info = { .pExpr = NULL, .visible = true }; info.field = *field; return taosArrayInsert(pFieldInfo->internalField, index, &info); diff --git a/tests/pytest/stable/json_tag.py b/tests/pytest/stable/json_tag.py index d953526ec4..78c63b10eb 100644 --- a/tests/pytest/stable/json_tag.py +++ b/tests/pytest/stable/json_tag.py @@ -194,7 +194,7 @@ class TDTestCase: tdSql.checkData(0, 0, "{\"k1\":\"\",\"k2\":true,\"k3\":false,\"k4\":55}") tdSql.query("select jtag->'k2' from db_json_tag_test.jsons1_10") - tdSql.checkData(0, 0, "true") + tdSql.checkData(0, 0, True) tdSql.query("select jtag from db_json_tag_test.jsons1 where jtag->'k1'=''") tdSql.checkRows(1) -- GitLab