From 5f28ee0e525812b48b7d8914993fc25c760db6f6 Mon Sep 17 00:00:00 2001 From: slzhou Date: Mon, 15 Apr 2024 11:28:09 +0800 Subject: [PATCH] fix: wrongly changed the column type of pk col during last row scan optimize --- source/libs/planner/src/planOptimizer.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index b3f50b540b..d5a25fb517 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2997,15 +2997,9 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic if (FUNCTION_TYPE_LAST == funcType) { nodesWalkExpr(nodesListGetNode(pFunc->pParameterList, 0), lastRowScanOptSetColDataType, &cxt); nodesListErase(pFunc->pParameterList, nodesListGetCell(pFunc->pParameterList, 1)); - if (pFunc->hasPk) { - if (LIST_LENGTH(pFunc->pParameterList) != 2) { - planError("last func which has pk but its parameter list length is not %d", 2); - nodesClearList(cxt.pLastCols); - taosArrayDestroy(isDuplicateCol); - return TSDB_CODE_PLAN_INTERNAL_ERROR; - } - nodesWalkExpr(nodesListGetNode(pFunc->pParameterList, 1), lastRowScanOptSetColDataType, &cxt); - } + } + if (pFunc->hasPk) { + nodesListMakeAppend(&cxt.pOtherCols, nodesListGetNode(pFunc->pParameterList, LIST_LENGTH(pFunc->pParameterList) - 1)); } } else { pNode = nodesListGetNode(pFunc->pParameterList, 0);