From 19f6766c9a181aeb27ce80e3dd63c4165e99585e Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Thu, 13 Jun 2024 19:14:44 +0800 Subject: [PATCH] fix: blockAgg --- include/common/tdatablock.h | 2 +- source/dnode/vnode/src/tsdb/tsdbRead2.c | 7 ++++++- source/libs/executor/src/executorInt.c | 2 +- source/libs/executor/src/groupoperator.c | 21 +++++++++++---------- source/libs/function/src/detail/tminmax.c | 23 ++++++++--------------- tests/army/test.py | 2 ++ 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 722f18c52d..ec998e9365 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -102,7 +102,7 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u return false; } - if (pColAgg != NULL) { + if (pColAgg != NULL && pColAgg->colId != -1) { if (pColAgg->numOfNull == totalRows) { ASSERT(pColumnInfoData->nullbitmap == NULL); return true; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 0771e4d5bf..b4aca0a8a1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -4959,6 +4959,12 @@ int32_t tsdbRetrieveDatablockSMA2(STsdbReader* pReader, SSDataBlock* pDataBlock, if (pResBlock->pBlockAgg == NULL) { size_t num = taosArrayGetSize(pResBlock->pDataBlock); pResBlock->pBlockAgg = taosMemoryCalloc(num, sizeof(SColumnDataAgg)); + if (pResBlock->pBlockAgg == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + for(int i = 0; i < num; ++i) { + pResBlock->pBlockAgg[i].colId = -1; + } } // do fill all null column value SMA info @@ -4976,7 +4982,6 @@ int32_t tsdbRetrieveDatablockSMA2(STsdbReader* pReader, SSDataBlock* pDataBlock, } else if (pAgg->colId < pSup->colId[j]) { i += 1; } else if (pSup->colId[j] < pAgg->colId) { - pResBlock->pBlockAgg[pSup->slotId[j]].colId = -1; *allHave = false; j += 1; } diff --git a/source/libs/executor/src/executorInt.c b/source/libs/executor/src/executorInt.c index 03b9a374c1..9326bfec43 100644 --- a/source/libs/executor/src/executorInt.c +++ b/source/libs/executor/src/executorInt.c @@ -435,7 +435,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) { int32_t slotId = pFuncParam->pCol->slotId; pInput->pColumnDataAgg[j] = &pBlock->pBlockAgg[slotId]; - if (pInput->pColumnDataAgg[j] == NULL) { + if (pInput->pColumnDataAgg[j]->colId == -1) { pInput->colDataSMAIsSet = false; } diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 88d5ac4c3c..0feaedaeef 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -591,17 +591,19 @@ SSDataBlock* createBlockDataNotLoaded(const SOperatorInfo* pOperator, SSDataBloc SColumnInfoData colInfo = {.hasNull = true, .info = pSrc->info}; blockDataAppendColInfo(pDstBlock, &colInfo); + pDstBlock->pBlockAgg[i].colId = -1; SColumnInfoData* pDst = taosArrayGet(pDstBlock->pDataBlock, i); - int32_t code = doEnsureCapacity(pDst, &pDstBlock->info, pDataBlock->info.rows, false); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - blockDataDestroy(pDstBlock); - return NULL; - } - colDataAssign(pDst, pSrc, pDataBlock->info.rows, &pDataBlock->info); - - if (pDataBlock->pBlockAgg) { + if (pDataBlock->pBlockAgg && pDataBlock->pBlockAgg[slotId].colId != -1) { pDstBlock->pBlockAgg[i] = pDataBlock->pBlockAgg[slotId]; + } else { + int32_t code = doEnsureCapacity(pDst, &pDstBlock->info, pDataBlock->info.rows, false); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + blockDataDestroy(pDstBlock); + return NULL; + } + + colDataAssign(pDst, pSrc, pDataBlock->info.rows, &pDataBlock->info); } } @@ -706,7 +708,6 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) { } dataNotLoadBlock->info.id.groupId = pGroupInfo->groupId; dataNotLoadBlock->info.dataLoad = 0; - pInfo->binfo.pRes->info.rows = pBlock->info.rows; taosArrayPush(pGroupInfo->blockForNotLoaded, &dataNotLoadBlock); break; } diff --git a/source/libs/function/src/detail/tminmax.c b/source/libs/function/src/detail/tminmax.c index a6c91a57ce..653b8adad7 100644 --- a/source/libs/function/src/detail/tminmax.c +++ b/source/libs/function/src/detail/tminmax.c @@ -702,23 +702,16 @@ static void doExtractVal(SColumnInfoData* pCol, int32_t i, int32_t end, SqlFunct } } -static int32_t saveRelatedTuple(SqlFunctionCtx* pCtx, SInputColumnInfoData* pInput, int32_t index, void* tval) { +static int32_t saveRelatedTupleTag(SqlFunctionCtx* pCtx, SInputColumnInfoData* pInput, void* tval) { SColumnInfoData* pCol = pInput->pData[0]; SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SMinmaxResInfo* pBuf = GET_ROWCELL_INTERBUF(pResInfo); - int32_t code = 0; + int32_t code = TSDB_CODE_SUCCESS; if (pCtx->subsidiaries.num > 0) { - index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); - if (index >= 0) { - code = saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } + code = saveTupleData(pCtx, 0, pCtx->pSrcBlock, &pBuf->tuplePos); } - return code; } @@ -758,7 +751,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) pBuf->v = GET_INT64_VAL(tval); } - code = saveRelatedTuple(pCtx, pInput, index, tval); + code = saveRelatedTupleTag(pCtx, pInput, tval); } else { if (IS_SIGNED_NUMERIC_TYPE(type)) { int64_t prev = 0; @@ -767,7 +760,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) int64_t val = GET_INT64_VAL(tval); if ((prev < val) ^ isMinFunc) { GET_INT64_VAL(&pBuf->v) = val; - code = saveRelatedTuple(pCtx, pInput, index, tval); + code = saveRelatedTupleTag(pCtx, pInput, tval); } } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { uint64_t prev = 0; @@ -776,7 +769,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) uint64_t val = GET_UINT64_VAL(tval); if ((prev < val) ^ isMinFunc) { GET_UINT64_VAL(&pBuf->v) = val; - code = saveRelatedTuple(pCtx, pInput, index, tval); + code = saveRelatedTupleTag(pCtx, pInput, tval); } } else if (type == TSDB_DATA_TYPE_DOUBLE) { double prev = 0; @@ -785,7 +778,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) double val = GET_DOUBLE_VAL(tval); if ((prev < val) ^ isMinFunc) { GET_DOUBLE_VAL(&pBuf->v) = val; - code = saveRelatedTuple(pCtx, pInput, index, tval); + code = saveRelatedTupleTag(pCtx, pInput, tval); } } else if (type == TSDB_DATA_TYPE_FLOAT) { float prev = 0; @@ -794,7 +787,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) float val = GET_DOUBLE_VAL(tval); if ((prev < val) ^ isMinFunc) { GET_FLOAT_VAL(&pBuf->v) = val; - code = saveRelatedTuple(pCtx, pInput, index, tval); + code = saveRelatedTupleTag(pCtx, pInput, tval); } } } diff --git a/tests/army/test.py b/tests/army/test.py index dda5d7d5b0..332d7f29c4 100644 --- a/tests/army/test.py +++ b/tests/army/test.py @@ -657,8 +657,10 @@ if __name__ == "__main__": conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) if fileName == "all": + tdLog.info("Procedures for testing runAllLinux") tdCases.runAllLinux(conn) else: + tdLog.info(f"Procedures for testing runOneLinux {fileName}") tdCases.runOneLinux(conn, fileName, replicaVar) # do restart option