-
Notifications
You must be signed in to change notification settings - Fork 190
[BUG] ROUND function returns FP result for FP value #1138
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What is the bug?
sql/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java
Lines 411 to 419 in 43ceda1
| FunctionDSL.impl( | |
| FunctionDSL.nullMissingHandling( | |
| v -> new ExprDoubleValue((double) Math.round(v.floatValue()))), | |
| DOUBLE, FLOAT), | |
| FunctionDSL.impl( | |
| FunctionDSL.nullMissingHandling( | |
| v -> new ExprDoubleValue(new BigDecimal(v.doubleValue()).setScale(0, | |
| RoundingMode.HALF_UP).doubleValue())), | |
| DOUBLE, DOUBLE), |
sql/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java
Lines 397 to 398 in 43ceda1
| * (x: FLOAT [, y: INTEGER]) -> FLOAT | |
| * (x: DOUBLE [, y: INTEGER]) -> DOUBLE |
How can one reproduce the bug?
opensearchsql> select typeof(round(1.1)), round(1.1);
fetched rows / total rows = 1/1
+----------------------+--------------+
| typeof(round(1.1)) | round(1.1) |
|----------------------+--------------|
| DOUBLE | 1.0 |
+----------------------+--------------+
What is the expected behavior?
ROUND function should return an integer value (INTEGER or LONG).
It may happen that returned FP value is not an integer number (has digits after the point).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working