From eed875268c3de339a515632630c606256330959c Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Wed, 8 Jun 2022 18:59:26 +0800 Subject: [PATCH] fix: compare group id first when choose tuple from loser tree --- source/libs/executor/src/tsort.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 846da4a32a..8fb1d1f302 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -359,6 +359,11 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) { SSDataBlock* pLeftBlock = pLeftSource->src.pBlock; SSDataBlock* pRightBlock = pRightSource->src.pBlock; + // first sort by block groupId + if (pLeftBlock->info.groupId != pRightBlock->info.groupId) { + return pLeftBlock->info.groupId < pRightBlock->info.groupId ? -1 : 1; + } + for(int32_t i = 0; i < pInfo->size; ++i) { SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, i); SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId); -- GitLab