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

add json tag support for group by

上级 d937ce6d
...@@ -3748,16 +3748,16 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd ...@@ -3748,16 +3748,16 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
for (int32_t i = 0; i < num; ++i) { for (int32_t i = 0; i < num; ++i) {
CommonItem * pItem = taosArrayGet(pList, i); CommonItem * pItem = taosArrayGet(pList, i);
SStrToken token = {0}; SStrToken token = {0};
if(pItem->isJsonExp){ // if(pItem->isJsonExp){
assert(pItem->jsonExp->tokenId == TK_ARROW); // assert(pItem->jsonExp->tokenId == TK_ARROW);
token.n = pItem->jsonExp->pLeft->value.nLen; // token.n = pItem->jsonExp->pLeft->value.nLen;
token.z = pItem->jsonExp->pLeft->value.pz; // token.z = pItem->jsonExp->pLeft->value.pz;
token.type = pItem->jsonExp->pLeft->value.nType; // token.type = pItem->jsonExp->pLeft->value.nType;
}else{ // }else{
token.n = pItem->pVar.nLen; token.n = pItem->pVar.nLen;
token.z = pItem->pVar.pz; token.z = pItem->pVar.pz;
token.type = pItem->pVar.nType; token.type = pItem->pVar.nType;
} // }
SColumnIndex index = COLUMN_INDEX_INITIALIZER; SColumnIndex index = COLUMN_INDEX_INITIALIZER;
if (getColumnIndexByName(&token, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { if (getColumnIndexByName(&token, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
...@@ -3793,11 +3793,11 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd ...@@ -3793,11 +3793,11 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
} }
SColIndex colIndex = { .colIndex = relIndex, .flag = TSDB_COL_TAG, .colId = pSchema->colId, }; SColIndex colIndex = { .colIndex = relIndex, .flag = TSDB_COL_TAG, .colId = pSchema->colId, };
if(pItem->isJsonExp) { // if(pItem->isJsonExp) {
tstrncpy(colIndex.name, pItem->jsonExp->pRight->value.pz, tListLen(colIndex.name)); // tstrncpy(colIndex.name, pItem->jsonExp->pRight->value.pz, tListLen(colIndex.name));
}else{ // }else{
tstrncpy(colIndex.name, pSchema->name, tListLen(colIndex.name)); tstrncpy(colIndex.name, pSchema->name, tListLen(colIndex.name));
} // }
taosArrayPush(pGroupExpr->columnInfo, &colIndex); taosArrayPush(pGroupExpr->columnInfo, &colIndex);
......
...@@ -80,11 +80,11 @@ typedef struct tVariantListItem { ...@@ -80,11 +80,11 @@ typedef struct tVariantListItem {
} tVariantListItem; } tVariantListItem;
typedef struct CommonItem { typedef struct CommonItem {
union { //union {
tVariant pVar; tVariant pVar;
struct tSqlExpr *jsonExp; //struct tSqlExpr *jsonExp;
}; //};
bool isJsonExp; //bool isJsonExp;
uint8_t sortOrder; uint8_t sortOrder;
} CommonItem; } CommonItem;
......
...@@ -529,12 +529,12 @@ SArray *commonItemAppend(SArray *pList, tVariant *pVar, tSqlExpr *jsonExp, bool ...@@ -529,12 +529,12 @@ SArray *commonItemAppend(SArray *pList, tVariant *pVar, tSqlExpr *jsonExp, bool
CommonItem item; CommonItem item;
item.sortOrder = sortOrder; item.sortOrder = sortOrder;
item.isJsonExp = isJsonExp; //item.isJsonExp = isJsonExp;
if(isJsonExp){ //if(isJsonExp){
item.jsonExp = jsonExp; //item.jsonExp = jsonExp;
}else{ //}else{
item.pVar = *pVar; item.pVar = *pVar;
} //}
taosArrayPush(pList, &item); taosArrayPush(pList, &item);
return pList; return pList;
...@@ -842,11 +842,11 @@ static void freeVariant(void *pItem) { ...@@ -842,11 +842,11 @@ static void freeVariant(void *pItem) {
static void freeCommonItem(void *pItem) { static void freeCommonItem(void *pItem) {
CommonItem* p = (CommonItem *) pItem; CommonItem* p = (CommonItem *) pItem;
if (p->isJsonExp){ //if (p->isJsonExp){
tSqlExprDestroy(p->jsonExp); //tSqlExprDestroy(p->jsonExp);
}else{ //}else{
tVariantDestroy(&p->pVar); tVariantDestroy(&p->pVar);
} //}
} }
void freeCreateTableInfo(void* p) { void freeCreateTableInfo(void* p) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册