提交 d1130391 编写于 作者: G Ganlin Zhao

fix(query): fix avg used in group by NULL value calculated as nan

TD-15892
上级 56c86a2a
...@@ -834,12 +834,14 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { ...@@ -834,12 +834,14 @@ 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);
} }
//check for overflow
if (isinf(pAvgRes->result) || isnan(pAvgRes->result)) {
GET_RES_INFO(pCtx)->isNullRes = 1;
}
return functionFinalize(pCtx, pBlock); return functionFinalize(pCtx, pBlock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册