-
Notifications
You must be signed in to change notification settings - Fork 190
[BUG] TRUNCATE functions returns incorrect result #1043
Copy link
Copy link
Closed
Labels
Description
What is the bug?
TRUNCATE functions returns incorrect result for some input data.
How can one reproduce the bug?
Test data:
ddouble_mapping.json.txt
ddouble.json.txt
curl -s -H 'Content-Type: application/json' -XPUT "http://localhost:9200/ddouble?pretty" -u admin:admin --insecure --data-binary @ddouble_mapping.json
curl -s -H 'Content-Type: application/json' -XPOST "http://localhost:9200/ddouble/_bulk?pretty" -u admin:admin --insecure --data-binary @ddouble.json | grep -i error
SELECT `ddouble`.`key`, `ddouble`.`val`, TRUNCATE(`ddouble`.`val`, 1) AS `EXPR$2` FROM `ddouble`What is your host/environment?
2.x @ 21373b9
Do you have any screenshots?
Do you have any additional context?
Reported on behalf of @kylepbit
sql/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java
Lines 506 to 507 in f8c58f1
| new BigDecimal(x.doubleValue()).setScale(y.integerValue(), | |
| RoundingMode.DOWN).doubleValue())), |
import java.math.BigDecimal
import java.math.RoundingMode
new BigDecimal(-1.2D).setScale(1, RoundingMode.DOWN).doubleValue() = -1.1Reactions are currently unavailable
