提交 1416efa5 编写于 作者: M Minglei Jin

fix(query): fix tag col check with groupby expr

上级 88c719c5
...@@ -8267,6 +8267,24 @@ static void updateTagPrjFunction(SQueryInfo* pQueryInfo) { ...@@ -8267,6 +8267,24 @@ static void updateTagPrjFunction(SQueryInfo* pQueryInfo) {
} }
} }
/*
retrun false : expr is not in groupbu column.
return true : expr is in groupby column.
*/
static bool check_expr_in_groupby_colum(SGroupbyExpr* pGroupbyExpr, SExprInfo* pExpr){
SColIndex* pIndex = NULL;
assert( pExpr);
if (NULL == pGroupbyExpr)
return false;
for (int32_t k = 0; k < pGroupbyExpr->numOfGroupCols ; ++k) {
pIndex = taosArrayGet(pGroupbyExpr->columnInfo, k);
if (!strcmp(pIndex->name,&pExpr->base.colInfo.name[1])){ // notes:first char is dot, skip one char.
return true;
}
}
return false;
}
/* /*
* check for selectivity function + tags column function both exist. * check for selectivity function + tags column function both exist.
* 1. tagprj functions are not compatible with aggregated function when missing "group by" clause * 1. tagprj functions are not compatible with aggregated function when missing "group by" clause
...@@ -8284,12 +8302,15 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { ...@@ -8284,12 +8302,15 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) {
int16_t numOfTimeWindow = 0; int16_t numOfTimeWindow = 0;
size_t numOfExprs = taosArrayGetSize(pQueryInfo->exprList); size_t numOfExprs = taosArrayGetSize(pQueryInfo->exprList);
SGroupbyExpr* pGroupbyExpr = &pQueryInfo->groupbyExpr;
for (int32_t i = 0; i < numOfExprs; ++i) { for (int32_t i = 0; i < numOfExprs; ++i) {
SExprInfo* pExpr = taosArrayGetP(pQueryInfo->exprList, i); SExprInfo* pExpr = taosArrayGetP(pQueryInfo->exprList, i);
if (pExpr->base.functionId == TSDB_FUNC_TAGPRJ || if (pExpr->base.functionId == TSDB_FUNC_TAGPRJ ||
(pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX)) { (pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX)) {
tagTsColExists = true; // selectivity + ts/tag column if (false == check_expr_in_groupby_colum(pGroupbyExpr,pExpr)) {
break; tagTsColExists = true; // selectivity + ts/tag column
break;
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册