[Bug] Double/Float % 0 should be NULL (#8230)

Co-authored-by: lihaopeng <lihaopeng@baidu.com>
This commit is contained in:
HappenLee
2022-02-25 11:03:42 +08:00
committed by GitHub
parent 4c5d7c27df
commit 8642fa38b9

View File

@ -113,7 +113,7 @@ FloatVal ModExpr::get_float_val(ExprContext* context, TupleRow* row) {
return FloatVal::null();
}
FloatVal v2 = _children[1]->get_float_val(context, row);
if (v2.is_null) {
if (v2.is_null || v2.val == 0) {
return FloatVal::null();
}
return FloatVal(fmod(v1.val, v2.val));
@ -125,7 +125,7 @@ DoubleVal ModExpr::get_double_val(ExprContext* context, TupleRow* row) {
return DoubleVal::null();
}
DoubleVal v2 = _children[1]->get_double_val(context, row);
if (v2.is_null) {
if (v2.is_null || v2.val == 0) {
return DoubleVal::null();
}
return DoubleVal(fmod(v1.val, v2.val));