fix: disable project elimination when the project node has parent

This commit is contained in:
shenglian zhou 2022-06-20 17:21:12 +08:00
parent c31ec19885
commit 56b5ff03e6
1 changed files with 6 additions and 2 deletions

View File

@ -1083,6 +1083,11 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
} }
static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) { static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) {
//TODO: enable this optimization after new mechanising that map projection and targets of project node
if (NULL != pNode->pParent) {
return false;
}
if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) { if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) {
return false; return false;
} }
@ -1122,10 +1127,9 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
SNode* pProjection = NULL; SNode* pProjection = NULL;
FOREACH(pProjection, pProjectNode->pProjections) { FOREACH(pProjection, pProjectNode->pProjections) {
SColumnNode* projColumn = (SColumnNode*)pProjection;
SNode* pChildTarget = NULL; SNode* pChildTarget = NULL;
FOREACH(pChildTarget, pChild->pTargets) { FOREACH(pChildTarget, pChild->pTargets) {
if (strcmp(projColumn->colName, ((SColumnNode*)pChildTarget)->colName) == 0) { if (strcmp(((SColumnNode*)pProjection)->colName, ((SColumnNode*)pChildTarget)->colName) == 0) {
nodesListAppend(pNewChildTargets, nodesCloneNode(pChildTarget)); nodesListAppend(pNewChildTargets, nodesCloneNode(pChildTarget));
break; break;
} }