diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index dc28b2ba316cf2661b5537e7ee89b820c877168b..de0feceb8f93159104fc53b12b2b4ff6f09293e8 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -560,13 +560,9 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, } if (NULL != pSelect->pGroupByList) { - if (NULL != pAgg->pGroupKeys) { - code = nodesListStrictAppendList(pAgg->pGroupKeys, nodesCloneList(pSelect->pGroupByList)); - } else { - pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList); - if (NULL == pAgg->pGroupKeys) { - code = TSDB_CODE_OUT_OF_MEMORY; - } + pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList); + if (NULL == pAgg->pGroupKeys) { + code = TSDB_CODE_OUT_OF_MEMORY; } } @@ -587,6 +583,8 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, if (TSDB_CODE_SUCCESS == code && NULL != pOutputGroupKeys) { code = createColumnByRewriteExprs(pOutputGroupKeys, &pAgg->node.pTargets); } + nodesDestroyList(pOutputGroupKeys); + if (TSDB_CODE_SUCCESS == code && NULL != pAgg->pAggFuncs) { code = createColumnByRewriteExprs(pAgg->pAggFuncs, &pAgg->node.pTargets); }