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

add json tag support for group by

上级 cd24c188
......@@ -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);
......
......@@ -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);
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册