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

add json tag support for group by

上级 50e4c037
...@@ -1903,7 +1903,6 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn ...@@ -1903,7 +1903,6 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
assert(right != NULL && right->type == SQL_NODE_VALUE); assert(right != NULL && right->type == SQL_NODE_VALUE);
tVariantAssign(&(pExpr->base.param[pExpr->base.numOfParams]), &right->value); tVariantAssign(&(pExpr->base.param[pExpr->base.numOfParams]), &right->value);
pExpr->base.numOfParams++; pExpr->base.numOfParams++;
assert(pExpr->base.numOfParams <= 3);
} }
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pIndex->tableIndex); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pIndex->tableIndex);
...@@ -3750,9 +3749,7 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd ...@@ -3750,9 +3749,7 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
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 = pItem->jsonExp->pLeft->columnName;
token.z = pItem->jsonExp->pLeft->value.pz;
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;
...@@ -7210,12 +7207,18 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) { ...@@ -7210,12 +7207,18 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static bool tagColumnInGroupby(SGroupbyExpr* pGroupbyExpr, int16_t columnId) { static bool tagColumnInGroupby(SGroupbyExpr* pGroupbyExpr, int16_t columnId, int16_t type, char* name) {
for (int32_t j = 0; j < pGroupbyExpr->numOfGroupCols; ++j) { for (int32_t j = 0; j < pGroupbyExpr->numOfGroupCols; ++j) {
SColIndex* pColIndex = taosArrayGet(pGroupbyExpr->columnInfo, j); SColIndex* pColIndex = taosArrayGet(pGroupbyExpr->columnInfo, j);
if (columnId == pColIndex->colId && TSDB_COL_IS_TAG(pColIndex->flag )) { if (type == TSDB_DATA_TYPE_JSON){
return true; if (columnId == pColIndex->colId && strncmp(pColIndex->name, name, tListLen(pColIndex->name)) == 0 && TSDB_COL_IS_TAG(pColIndex->flag )) {
return true;
}
}else{
if (columnId == pColIndex->colId && TSDB_COL_IS_TAG(pColIndex->flag )) {
return true;
}
} }
} }
...@@ -7250,7 +7253,7 @@ static bool allTagPrjInGroupby(SQueryInfo* pQueryInfo) { ...@@ -7250,7 +7253,7 @@ static bool allTagPrjInGroupby(SQueryInfo* pQueryInfo) {
continue; continue;
} }
if (!tagColumnInGroupby(&pQueryInfo->groupbyExpr, pExpr->base.colInfo.colId)) { if (!tagColumnInGroupby(&pQueryInfo->groupbyExpr, pExpr->base.colInfo.colId, pExpr->base.resType, pExpr->base.param[0].pz)) {
allInGroupby = false; allInGroupby = false;
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册