diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index d78b4b8093ae6d2341795510f1f2f3eaea230fb4..1fb63d51b2d16da0158a6486ceb0ec88cb22fecd 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3710,6 +3710,8 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd const char* msg6 = "tags not allowed for table query"; const char* msg7 = "not support group by expression"; const char* msg8 = "normal column can only locate at the end of group by clause"; + const char* msg9 = "json tag must be use ->'key'"; + const char* msg10 = "non json column can not use ->'key'"; // todo : handle two tables situation STableMetaInfo* pTableMetaInfo = NULL; @@ -3776,6 +3778,13 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); } + if (pSchema->type == TSDB_DATA_TYPE_JSON && !pItem->isJsonExp){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9); + } + if (pSchema->type != TSDB_DATA_TYPE_JSON && pItem->isJsonExp){ + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10); + } + int32_t numOfCols = tscGetNumOfColumns(pTableMeta); bool groupTag = (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX || index.columnIndex >= numOfCols); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 32f6bd33be89d286c6fa43feb9ec89c0e45b3d45..bfdc23154c4fa916036b87c6b4d59b02fd7b6c87 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3396,7 +3396,7 @@ static void doSetTagValueInParam(void* pTable, char* param, int32_t paramLen, in //tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type); } else if(type == TSDB_DATA_TYPE_JSON){ char jsonVal[TSDB_MAX_JSON_TAGS_LEN] = {0}; - if(param && paramLen > 0){ + if(param){ getJsonTagValueElment(pTable, param, paramLen, jsonVal, bytes); }else{ getJsonTagValueAll(val, jsonVal, TSDB_MAX_JSON_TAGS_LEN);