From 46e76fc2eec22dac0b660cb619689520061b0343 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 14 May 2022 16:40:51 +0800 Subject: [PATCH] fix(query): fix a corner case for generating the filtered ssdatablock. --- source/libs/executor/src/executorimpl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 2d3c0d90d7..556f094528 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -2146,6 +2146,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR SSDataBlock* px = createOneDataBlock(pBlock, false); blockDataEnsureCapacity(px, pBlock->info.rows); + int32_t totalRows = pBlock->info.rows; + for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { SColumnInfoData* pDst = taosArrayGet(px->pDataBlock, i); SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, i); @@ -2156,7 +2158,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR } int32_t numOfRows = 0; - for (int32_t j = 0; j < pBlock->info.rows; ++j) { + for (int32_t j = 0; j < totalRows; ++j) { if (rowRes[j] == 0) { continue; } @@ -2169,7 +2171,12 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR numOfRows += 1; } - pBlock->info.rows = numOfRows; + if (pBlock->info.rows == totalRows) { + pBlock->info.rows = numOfRows; + } else { + ASSERT(pBlock->info.rows == numOfRows); + } + *pSrc = *pDst; } } else { -- GitLab