diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 7f4108fb59e1d55d888956778d5f7da40b0d8b67..f8da21518a335308ac883ba585a62f642b114867 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3748,16 +3748,16 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd for (int32_t i = 0; i < num; ++i) { CommonItem * pItem = taosArrayGet(pList, i); SStrToken token = {0}; -// if(pItem->isJsonExp){ -// assert(pItem->jsonExp->tokenId == TK_ARROW); -// token.n = pItem->jsonExp->pLeft->value.nLen; -// token.z = pItem->jsonExp->pLeft->value.pz; -// token.type = pItem->jsonExp->pLeft->value.nType; -// }else{ + if(pItem->isJsonExp){ + assert(pItem->jsonExp->tokenId == TK_ARROW); + token.n = pItem->jsonExp->pLeft->value.nLen; + token.z = pItem->jsonExp->pLeft->value.pz; + token.type = pItem->jsonExp->pLeft->value.nType; + }else{ token.n = pItem->pVar.nLen; token.z = pItem->pVar.pz; token.type = pItem->pVar.nType; -// } + } SColumnIndex index = COLUMN_INDEX_INITIALIZER; if (getColumnIndexByName(&token, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { @@ -3793,11 +3793,11 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd } SColIndex colIndex = { .colIndex = relIndex, .flag = TSDB_COL_TAG, .colId = pSchema->colId, }; -// if(pItem->isJsonExp) { -// tstrncpy(colIndex.name, pItem->jsonExp->pRight->value.pz, tListLen(colIndex.name)); -// }else{ + if(pItem->isJsonExp) { + tstrncpy(colIndex.name, pItem->jsonExp->pRight->value.pz, tListLen(colIndex.name)); + }else{ tstrncpy(colIndex.name, pSchema->name, tListLen(colIndex.name)); -// } + } taosArrayPush(pGroupExpr->columnInfo, &colIndex); diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 2b9b42fee50951708732629629d354e458f9fd7e..363240636c81fe3698e58d95842ffb02f64cda33 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -80,11 +80,11 @@ typedef struct tVariantListItem { } tVariantListItem; typedef struct CommonItem { - //union { + union { tVariant pVar; - //struct tSqlExpr *jsonExp; - //}; - //bool isJsonExp; + struct tSqlExpr *jsonExp; + }; + bool isJsonExp; uint8_t sortOrder; } CommonItem; @@ -280,6 +280,7 @@ typedef struct tSqlExprItem { bool distinct; } tSqlExprItem; +SArray *commonItemAppend(SArray *pList, tVariant *pVar, tSqlExpr *jsonExp, bool isJsonExp, uint8_t sortOrder); SArray *tVariantListAppend(SArray *pList, tVariant *pVar, uint8_t sortOrder); SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int32_t index); SArray *tVariantListAppendToken(SArray *pList, SStrToken *pAliasToken, uint8_t sortOrder); diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index b97829663a21033751fd4fb6d2c8ccf301b68963..03a2a6666ed5164ca0d71e04c7ba3e77afed6714 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -529,12 +529,12 @@ SArray *commonItemAppend(SArray *pList, tVariant *pVar, tSqlExpr *jsonExp, bool CommonItem item; item.sortOrder = sortOrder; - //item.isJsonExp = isJsonExp; - //if(isJsonExp){ - //item.jsonExp = jsonExp; - //}else{ + item.isJsonExp = isJsonExp; + if(isJsonExp){ + item.jsonExp = jsonExp; + }else{ item.pVar = *pVar; - //} + } taosArrayPush(pList, &item); return pList; @@ -842,11 +842,11 @@ static void freeVariant(void *pItem) { static void freeCommonItem(void *pItem) { CommonItem* p = (CommonItem *) pItem; - //if (p->isJsonExp){ - //tSqlExprDestroy(p->jsonExp); - //}else{ + if (p->isJsonExp){ + tSqlExprDestroy(p->jsonExp); + }else{ tVariantDestroy(&p->pVar); - //} + } } void freeCreateTableInfo(void* p) {