提交 dcb856e9 编写于 作者: wmmhello's avatar wmmhello

add json tag support for group by

上级 0170c3bb
...@@ -3710,6 +3710,8 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd ...@@ -3710,6 +3710,8 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
const char* msg6 = "tags not allowed for table query"; const char* msg6 = "tags not allowed for table query";
const char* msg7 = "not support group by expression"; 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* 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 // todo : handle two tables situation
STableMetaInfo* pTableMetaInfo = NULL; STableMetaInfo* pTableMetaInfo = NULL;
...@@ -3776,6 +3778,13 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd ...@@ -3776,6 +3778,13 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); 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); int32_t numOfCols = tscGetNumOfColumns(pTableMeta);
bool groupTag = (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX || index.columnIndex >= numOfCols); bool groupTag = (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX || index.columnIndex >= numOfCols);
......
...@@ -3396,7 +3396,7 @@ static void doSetTagValueInParam(void* pTable, char* param, int32_t paramLen, in ...@@ -3396,7 +3396,7 @@ static void doSetTagValueInParam(void* pTable, char* param, int32_t paramLen, in
//tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type); //tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type);
} else if(type == TSDB_DATA_TYPE_JSON){ } else if(type == TSDB_DATA_TYPE_JSON){
char jsonVal[TSDB_MAX_JSON_TAGS_LEN] = {0}; char jsonVal[TSDB_MAX_JSON_TAGS_LEN] = {0};
if(param && paramLen > 0){ if(param){
getJsonTagValueElment(pTable, param, paramLen, jsonVal, bytes); getJsonTagValueElment(pTable, param, paramLen, jsonVal, bytes);
}else{ }else{
getJsonTagValueAll(val, jsonVal, TSDB_MAX_JSON_TAGS_LEN); getJsonTagValueAll(val, jsonVal, TSDB_MAX_JSON_TAGS_LEN);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册