From 02e097dc5cd848e8a99d2d479ddadb04fd9a502a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 31 Mar 2022 17:36:51 +0800 Subject: [PATCH] [td-14426] fix bug. --- include/common/tcommon.h | 4 ++-- source/libs/executor/src/executorimpl.c | 6 +++--- source/libs/scalar/src/sclvector.c | 14 +++++++------- source/util/src/tcompare.c | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 51eabb7d61..988bf3f4e8 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -198,8 +198,8 @@ typedef struct SGroupbyExpr { } SGroupbyExpr; enum { - FUNC_PARAM_TYPE_VALUE = 0, - FUNC_PARAM_TYPE_COLUMN, + FUNC_PARAM_TYPE_VALUE = 0x1, + FUNC_PARAM_TYPE_COLUMN= 0x2, }; typedef struct SFunctParam { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index d97b3183f2..8e4e33c997 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1258,8 +1258,8 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, ASSERT(pCtx[i].input.pData[j] != NULL); } } - // setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns); + // setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns); // uint32_t flag = pOperator->pExpr[i].base.pParam[0].pCol->flag; // if (TSDB_COL_IS_NORMAL_COL(flag) /*|| (pCtx[i].functionId == FUNCTION_BLKINFO) || // (TSDB_COL_IS_TAG(flag) && pOperator->pRuntimeEnv->scanFlag == MERGE_STAGE)*/) { @@ -8771,8 +8771,8 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* pExp->pExpr->_optrRoot.pRootNode = pTargetNode->pExpr; - pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN; - pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType); +// pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN; +// pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType); } else { ASSERT(0); } diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index f22f9a5c3c..33be65832c 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -720,7 +720,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i); double rx = getVectorDoubleValueFnRight(pRightCol->pData, i); - if (compareDoubleVal(&zero, &rx)) { + if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx)) { colDataAppend(pOutputCol, i, NULL, true); continue; } @@ -729,7 +729,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } } else if (pLeft->numOfRows == 1) { double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, 0); - if (colDataIsNull_f(pLeftCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + if (colDataIsNull_f(pLeftCol->nullbitmap, 0) || isnan(lx) || isinf(lx)) { // Set pLeft->numOfRows NULL value // TODO set numOfRows NULL value } else { for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) { @@ -739,7 +739,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } double rx = getVectorDoubleValueFnRight(pRightCol->pData, i); - if (compareDoubleVal(&zero, &rx)) { + if (isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) { colDataAppend(pOutputCol, i, NULL, true); continue; } @@ -749,17 +749,17 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } } else if (pRight->numOfRows == 1) { double rx = getVectorDoubleValueFnRight(pRightCol->pData, 0); - if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + if (colDataIsNull_f(pRightCol->nullbitmap, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value // TODO set numOfRows NULL value } else { for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) { - if (colDataIsNull_f(pRightCol->nullbitmap, i)) { + if (colDataIsNull_f(pLeftCol->nullbitmap, i)) { colDataAppend(pOutputCol, i, NULL, true); continue; } - double lx = getVectorDoubleValueFnLeft(pRightCol->pData, i); - if (compareDoubleVal(&zero, &lx)) { + double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i); + if (isnan(lx) || isinf(lx)) { colDataAppend(pOutputCol, i, NULL, true); continue; } diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index c98f6eb9be..7f9a3ff593 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -173,6 +173,7 @@ int32_t compareDoubleVal(const void *pLeft, const void *pRight) { if (isnan(p2)) { return 1; } + if (FLT_EQUAL(p1, p2)) { return 0; }