diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 4677b5d5f0..30cc552761 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -2960,7 +2960,16 @@ static SNode* nodesListFindNode(SNodeList* pList, SNode* pNode) { } int32_t nodesListDeduplicate(SNodeList** ppList) { - if (!ppList || LIST_LENGTH(*ppList) == 0) return TSDB_CODE_SUCCESS; + if (!ppList || LIST_LENGTH(*ppList) <= 1) return TSDB_CODE_SUCCESS; + if (LIST_LENGTH(*ppList) == 2) { + SNode* pNode1 = nodesListGetNode(*ppList, 0); + SNode* pNode2 = nodesListGetNode(*ppList, 1); + if (nodesEqualNode(pNode1, pNode2)) { + SListCell* pCell = nodesListGetCell(*ppList, 1); + (void)nodesListErase(*ppList, pCell); + } + return TSDB_CODE_SUCCESS; + } SNodeList* pTmp = NULL; int32_t code = nodesMakeList(&pTmp); if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 778c34ff02..9702c2e760 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -326,7 +326,6 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) { int32_t code = calcConstList(pSelect->pGroupByList); -#if 0 if (TSDB_CODE_SUCCESS == code) { SNode* pNode = NULL; FOREACH(pNode, pSelect->pGroupByList) { @@ -337,9 +336,11 @@ static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) { } } } - NODES_DESTORY_LIST(pSelect->pGroupByList); + FOREACH(pNode, pSelect->pGroupByList) { + if (!cell->pPrev) continue; + ERASE_NODE(pSelect->pGroupByList); + } } -#endif return code; }