[fix](Nereids) decimal divide should not return null if numerator is zero (#22309)

This commit is contained in:
谢健
2023-07-27 20:23:04 +08:00
committed by GitHub
parent 687d97e648
commit 716d58f5ff
3 changed files with 5 additions and 1 deletions

View File

@ -584,7 +584,7 @@ public class NumericArithmetic {
*/
@ExecFunction(name = "divide", argTypes = {"DECIMALV3", "DECIMALV3"}, returnType = "DECIMALV3")
public static Expression divideDecimalV3(DecimalV3Literal first, DecimalV3Literal second) {
if (first.getValue().compareTo(BigDecimal.ZERO) == 0) {
if (second.getValue().compareTo(BigDecimal.ZERO) == 0) {
return new NullLiteral(first.getDataType());
}
DecimalV3Type t1 = (DecimalV3Type) first.getDataType();

View File

@ -19,3 +19,6 @@
-- !select --
2 2020-01-01
-- !select --
\N 0.00000

View File

@ -59,5 +59,6 @@ suite("fold_constant") {
qt_select "select * from d_table2 order by 1;"
sql "delete from d_table2 where k1=3+1;"
qt_select "select * from d_table2 order by 1;"
qt_select "select 10.0/0, 0.0/10"
}