Skip to content

Commit

Permalink
fix regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Dec 18, 2022
1 parent f8f97a5 commit d596c1c
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.apache.doris.nereids.trees.expressions.literal.DecimalLiteral;
import org.apache.doris.nereids.trees.expressions.literal.DoubleLiteral;
import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral;
import org.apache.doris.nereids.trees.expressions.literal.Literal;
import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
import org.apache.doris.nereids.trees.expressions.literal.SmallIntLiteral;
import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral;

Expand Down Expand Up @@ -153,18 +155,18 @@ public static DecimalLiteral multiplyDecimal(DecimalLiteral first, DecimalLitera
}

@ExecFunction(name = "divide", argTypes = {"DOUBLE", "DOUBLE"}, returnType = "DOUBLE")
public static DoubleLiteral divideDouble(DoubleLiteral first, DoubleLiteral second) {
public static Literal divideDouble(DoubleLiteral first, DoubleLiteral second) {
if (second.getValue() == 0.0) {
return null;
return new NullLiteral(first.getDataType());
}
double result = first.getValue() / second.getValue();
return new DoubleLiteral(result);
}

@ExecFunction(name = "divide", argTypes = {"DECIMAL", "DECIMAL"}, returnType = "DECIMAL")
public static DecimalLiteral divideDecimal(DecimalLiteral first, DecimalLiteral second) {
public static Literal divideDecimal(DecimalLiteral first, DecimalLiteral second) {
if (first.getValue().compareTo(BigDecimal.ZERO) == 0) {
return null;
return new NullLiteral(first.getDataType());
}
BigDecimal result = first.getValue().divide(second.getValue());
return new DecimalLiteral(result);
Expand Down

0 comments on commit d596c1c

Please sign in to comment.