diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index d574fdbdefe968d7091a63bbfe9f5221ba72783a..7a22be880cec77c0cc0e09a495f4f6ada1184562 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2322,7 +2322,10 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t if (tokenId == TK_ARROW && pSchema->type != TSDB_DATA_TYPE_JSON) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); } - + if(pSchema->type == TSDB_DATA_TYPE_JSON && tokenId == TK_ARROW){ + pItem->aliasName = calloc(1, pItem->pNode->exprToken.n + 1); + memcpy(pItem->aliasName, pItem->pNode->exprToken.z, pItem->pNode->exprToken.n); + } addProjectQueryCol(pQueryInfo, startPos, &index, pItem, getNewResColId(pCmd)); pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; } diff --git a/tests/pytest/stable/json_tag.py b/tests/pytest/stable/json_tag.py index 27be0b7eacaaa9ceb37927eae2c8c9736962341f..e48f340d59f34af551e513cba7b3cf6800dddbf6 100644 --- a/tests/pytest/stable/json_tag.py +++ b/tests/pytest/stable/json_tag.py @@ -235,7 +235,13 @@ class TDTestCase: tdSql.checkRows(3) # test chinese - tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_11 using db_json_tag_test.jsons1 tags('{\"k1\":\"中国\",\"k2\":\"是是是\"}')") + tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_11 using db_json_tag_test.jsons1 tags('{\"k1\":\"中国\",\"k5\":\"是是是\"}')") + + tdSql.query("select tbname,jtag from db_json_tag_test.jsons1 where jtag->'k1' match '中'") + tdSql.checkRows(1) + + tdSql.query("select tbname,jtag from db_json_tag_test.jsons1 where jtag->'k1'='中国'") + tdSql.checkRows(1) def stop(self): tdSql.close()