diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c7f0e1fe19cc234cbf3b6233a46b8c1e81263efa..7016eec367dfe11931e14c991705db5240645a9c 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2199,6 +2199,7 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi char keyMd5[TSDB_MAX_JSON_KEY_MD5_LEN + 1] = {0}; jsonKeyMd5(fieldName, strlen(fieldName), keyMd5); strncpy(pInfo->fieldJson.name, keyMd5, sizeof(pInfo->fieldJson.name)); + pInfo->fieldJson.type = TSDB_DATA_TYPE_JSON; } pInfo->pExpr = pSqlExpr; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 2e6cee31bf39bc26da9773433282729eb9811557..9224a13c25ce77dbbb5804f0a7bfc7ae4e57a6f7 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2655,12 +2655,11 @@ static void updateFieldForJson(SSqlObj *pSql, SQueryTableRsp *pQueryAttr){ SInternalField *pField = tscFieldInfoGetInternalField(pFieldInfo, i); if (pField->field.type == TSDB_DATA_TYPE_JSON) { - pField->fieldJson.type = TSDB_DATA_TYPE_JSON; for (int k = 0; k < pQueryAttr->tJsonSchLen; ++k) { if (strncmp(pField->fieldJson.name, pQueryAttr->tagJsonSchema[k].name, TSDB_MAX_JSON_KEY_LEN) == 0 && pQueryAttr->tagJsonSchema[k].type != TSDB_DATA_TYPE_JSON) { pField->fieldJson.type = pQueryAttr->tagJsonSchema[k].type; - pField->fieldJson.bytes = TYPE_BYTES[pField->field.type]; + pField->fieldJson.bytes = TYPE_BYTES[pField->fieldJson.type]; tscDebug("0x%" PRIx64 " change json type %s:%s to %d", pSql->self, pField->field.name, pQueryAttr->tagJsonSchema[k].name, pField->fieldJson.type); break; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 672d385cc5cb88c5227e0035934abcbf0b99a376..37482389f81bfba3734a36ac00752f612eae9b30 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 && pField->fieldJson.type != TSDB_DATA_TYPE_NULL){ + if(f[j].type == TSDB_DATA_TYPE_JSON){ 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;