fix(query): fix avg/sum function result overflown output inf/nan
TD-15923
This commit is contained in:
parent
e27f8e8a23
commit
72d9b07894
|
@ -502,6 +502,11 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check for overflow
|
||||||
|
if (isinf(pSumRes->dsum) || isnan(pSumRes->dsum)) {
|
||||||
|
GET_RES_INFO(pCtx)->isNullRes = 1;
|
||||||
|
}
|
||||||
|
|
||||||
_sum_over:
|
_sum_over:
|
||||||
// data in the check operation are all null, not output
|
// data in the check operation are all null, not output
|
||||||
SET_VAL(GET_RES_INFO(pCtx), numOfElem, 1);
|
SET_VAL(GET_RES_INFO(pCtx), numOfElem, 1);
|
||||||
|
@ -813,6 +818,9 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
if (IS_INTEGER_TYPE(type)) {
|
if (IS_INTEGER_TYPE(type)) {
|
||||||
pAvgRes->result = pAvgRes->sum.isum / ((double)pAvgRes->count);
|
pAvgRes->result = pAvgRes->sum.isum / ((double)pAvgRes->count);
|
||||||
} else {
|
} else {
|
||||||
|
if (isinf(pAvgRes->sum.dsum) || isnan(pAvgRes->sum.dsum)) {
|
||||||
|
GET_RES_INFO(pCtx)->isNullRes = 1;
|
||||||
|
}
|
||||||
pAvgRes->result = pAvgRes->sum.dsum / ((double)pAvgRes->count);
|
pAvgRes->result = pAvgRes->sum.dsum / ((double)pAvgRes->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue