diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index d58df3e8766606d9343eb309e19462dadee617f0..306b43834440f65b5307b9949b90ac77e7ad60f0 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -63,7 +63,7 @@ static int32_t translateInNumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_t } uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_NUMERIC_TYPE(paraType)) { + if (!IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 77126225bf3989b4406a89b71d507088bff6e384..90632256b2cbc47dd2196f1167570f357d5edf52 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -542,6 +542,12 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; int32_t numOfRows = pInput->numOfRows; + if (IS_NULL_TYPE(type)) { + GET_RES_INFO(pCtx)->isNullRes = 1; + numOfElem = 1; + goto _avg_over; + } + switch (type) { case TSDB_DATA_TYPE_TINYINT: { int8_t* plist = (int8_t*)pCol->pData; @@ -633,6 +639,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) { break; } +_avg_over: // data in the check operation are all null, not output SET_VAL(GET_RES_INFO(pCtx), numOfElem, 1); return TSDB_CODE_SUCCESS; @@ -1330,6 +1337,12 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; int32_t numOfRows = pInput->numOfRows; + if (IS_NULL_TYPE(type)) { + GET_RES_INFO(pCtx)->isNullRes = 1; + numOfElem = 1; + goto _stddev_over; + } + switch (type) { case TSDB_DATA_TYPE_TINYINT: { int8_t* plist = (int8_t*)pCol->pData; @@ -1427,6 +1440,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) { break; } +_stddev_over: // data in the check operation are all null, not output SET_VAL(GET_RES_INFO(pCtx), numOfElem, 1); return TSDB_CODE_SUCCESS;