From 049c6724119a1cd26101d1576d01c5454f986b8e Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 29 Nov 2022 14:21:45 +0800 Subject: [PATCH] fix: planner error --- source/libs/planner/src/planLogicCreater.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 44eb8478f1..e0a67c32e5 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -580,15 +580,19 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, } // set the output - 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); } + if (TSDB_CODE_SUCCESS == code) { + if (NULL != pOutputGroupKeys) { + code = createColumnByRewriteExprs(pOutputGroupKeys, &pAgg->node.pTargets); + } else if (NULL == pAgg->node.pTargets && NULL != pAgg->pGroupKeys) { + code = createColumnByRewriteExprs(pAgg->pGroupKeys, &pAgg->node.pTargets); + } + } + nodesDestroyList(pOutputGroupKeys); + if (TSDB_CODE_SUCCESS == code) { *pLogicNode = (SLogicNode*)pAgg; } else { -- GitLab