diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index e7876b6a7adff83a5942394a931566288baa13fc..c80aca3a4a5174aa0e9d0a9087d3df931c1f6928 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1841,7 +1841,7 @@ int tscProcessRetrieveGlobalMergeRsp(SSqlObj *pSql) { uint64_t localQueryId = pSql->self; qTableQuery(pQueryInfo->pQInfo, &localQueryId); bool convertJson = true; - if (tscMultiRoundQuery(pQueryInfo, 0)) convertJson = false; + if (pQueryInfo->isStddev == true) convertJson = false; convertQueryResult(pRes, pQueryInfo, pSql->self, true, convertJson); code = pRes->code; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 610128b57838fbaeb2c435b86a1fe79b64220392..1b0591c6b824032b5f81aa74c855fb4728cda05f 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -2450,6 +2450,7 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0); tscInitQueryInfo(pNewQueryInfo); + pNewQueryInfo->isStddev = true; // for json tag // add the group cond pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr; @@ -3708,7 +3709,7 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql) { int32_t type = pInfo->field.type; int32_t bytes = pInfo->field.bytes; - if (tscMultiRoundQuery(pQueryInfo, 0) && pQueryInfo->round == 0 && type == TSDB_DATA_TYPE_JSON){ // for json tag compare in the second round of stddev + if (pQueryInfo->isStddev && type == TSDB_DATA_TYPE_JSON){ // for json tag compare in the second round of stddev pRes->tsrow[j] = pRes->urow[i]; }else if (!IS_VAR_DATA_TYPE(type) && type != TSDB_DATA_TYPE_JSON) { pRes->tsrow[j] = isNull(pRes->urow[i], type) ? NULL : pRes->urow[i]; diff --git a/src/query/inc/qTableMeta.h b/src/query/inc/qTableMeta.h index 87143117813c795a2ea0f052779cff171eb3d8f0..d47189691ebbe2c4ec3ad55dd72306686586a56e 100644 --- a/src/query/inc/qTableMeta.h +++ b/src/query/inc/qTableMeta.h @@ -166,6 +166,7 @@ typedef struct SQueryInfo { bool stateWindow; bool globalMerge; bool multigroupResult; + bool isStddev; } SQueryInfo; /** diff --git a/tests/pytest/stable/json_tag.py b/tests/pytest/stable/json_tag.py index 514d05c5877622f8598e76646a237674620e0bdb..efabcb578ddaa38bc7d845cecb5200d5a24f4a99 100644 --- a/tests/pytest/stable/json_tag.py +++ b/tests/pytest/stable/json_tag.py @@ -105,7 +105,6 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query("select jtag->'sex' from db_json_tag_test.jsons1 where jtag?'sex' or jtag?'num'") - tdSql.checkData(0, 0, "\"femail\"") tdSql.checkRows(3) tdSql.query("select *,tbname from db_json_tag_test.jsons1 where jtag->'location'='beijing'") @@ -290,6 +289,11 @@ class TDTestCase: tdSql.checkData(1, 2, 1) tdSql.checkData(3, 2, 11) + tdSql.query("select stddev(dataint) from db_json_tag_test.jsons1 group by jtag->'location'") + tdSql.checkData(0, 1, None) + tdSql.checkData(1, 0, 0.5) + tdSql.checkData(2, 0, 0) + # test json->'key'=null tdSql.execute("insert into db_json_tag_test.jsons1_9 values('2020-04-17 15:20:00.000', 5, false, 'json19')") tdSql.query("select * from db_json_tag_test.jsons1")