From f9f4066f3c9600be9bf95d51b021f9c4ab131ae7 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 24 Feb 2023 17:17:55 +0800 Subject: [PATCH] fix(query): fix apply limit error for doMultiwayMerge operator if datablocks within same group --- source/libs/executor/src/sortoperator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index dc3ab79afb..4095fd9443 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -671,7 +671,9 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData } bool limitReached = applyLimitOffset(&pInfo->limitInfo, p, pTaskInfo); - if (limitReached) { + // if limit is reached within a group, do not clear limiInfo otherwise the next block + // will be processed. + if (newgroup && limitReached) { resetLimitInfoForNextGroup(&pInfo->limitInfo); }