From d54e345dc96b735803c3db05ff1c8dd8403e58ab Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 13 May 2022 21:00:46 +0800 Subject: [PATCH 1/2] fix: ensure capacity before column merge: select agg1(col/10), agg2(col/2) --- source/libs/executor/src/executorimpl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 8db5a282d3..b5c6daa69c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -898,6 +898,7 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest); int32_t startOffset = createNewColModel ? 0 : pResult->info.rows; + colInfoDataEnsureCapacity(pResColData, startOffset, pResult->info.capacity); colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows); numOfRows = dest.numOfRows; @@ -937,6 +938,7 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc } int32_t startOffset = createNewColModel ? 0 : pResult->info.rows; + colInfoDataEnsureCapacity(pResColData, startOffset, pResult->info.capacity); colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows); numOfRows = dest.numOfRows; From a6900a7e961649a4e3e1f57502b204d8ac9a3d3b Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 13 May 2022 21:02:32 +0800 Subject: [PATCH 2/2] fix : udf2 overflow for large int multiply large int --- source/libs/function/test/udf2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/function/test/udf2.c b/source/libs/function/test/udf2.c index ba39b09f56..6410af2a4b 100644 --- a/source/libs/function/test/udf2.c +++ b/source/libs/function/test/udf2.c @@ -44,7 +44,7 @@ int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInte case TSDB_DATA_TYPE_INT: { char* cell = udfColDataGetData(col, j); int32_t num = *(int32_t*)cell; - sumSquares += num * num; + sumSquares += (double)num * num; break; } case TSDB_DATA_TYPE_DOUBLE: {