fix: disable tag scan when the grouping set is not column and distince would create grouping keys consisted of grouping set
This commit is contained in:
parent
c8969d0ec4
commit
a8325b09e0
|
@ -884,9 +884,17 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe
|
|||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
// set grouyp keys, agg funcs and having conditions
|
||||
pAgg->pGroupKeys = nodesCloneList(pSelect->pProjectionList);
|
||||
if (NULL == pAgg->pGroupKeys) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
SNodeList* pGroupKeys = NULL;
|
||||
SNode* pProjection = NULL;
|
||||
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
|
||||
|
|
|
@ -2149,7 +2149,16 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) {
|
|||
planOptNodeListHasCol(pAgg->pGroupKeys) || !planOptNodeListHasTbname(pAgg->pGroupKeys)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue