未验证 提交 c88c56a7 编写于 作者: S shenglian-zhou 提交者: GitHub

Merge pull request #15273 from taosdata/szhou/fix/td-17601

fix: disable tag scan when the grouping set is not column and distince would create grouping keys consisted of grouping set
...@@ -884,9 +884,17 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe ...@@ -884,9 +884,17 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
// set grouyp keys, agg funcs and having conditions // set grouyp keys, agg funcs and having conditions
pAgg->pGroupKeys = nodesCloneList(pSelect->pProjectionList); SNodeList* pGroupKeys = NULL;
if (NULL == pAgg->pGroupKeys) { SNode* pProjection = NULL;
code = TSDB_CODE_OUT_OF_MEMORY; FOREACH(pProjection, pSelect->pProjectionList) {
code = nodesListMakeStrictAppend(&pGroupKeys, createGroupingSetNode(pProjection));
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyList(pGroupKeys);
break;
}
}
if (TSDB_CODE_SUCCESS == code) {
pAgg->pGroupKeys = pGroupKeys;
} }
// rewrite the expression in subsequent clauses // rewrite the expression in subsequent clauses
......
...@@ -2150,6 +2150,15 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) { ...@@ -2150,6 +2150,15 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) {
return false; return false;
} }
SNode* pGroupKey = NULL;
FOREACH(pGroupKey, pAgg->pGroupKeys) {
SNode* pGroup = NULL;
FOREACH(pGroup, ((SGroupingSetNode*)pGroupKey)->pParameterList) {
if (QUERY_NODE_COLUMN != nodeType(pGroup)) {
return false;
}
}
}
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册