Skip to content

Round error when casting float to decimal #4071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andygrove opened this issue Nov 1, 2022 · 2 comments
Closed

Round error when casting float to decimal #4071

andygrove opened this issue Nov 1, 2022 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@andygrove
Copy link
Member

andygrove commented Nov 1, 2022

Describe the bug

Spark

scala> spark.sql("select cast(0.06+0.01 as decimal(18,2))").show
+------------------------------------+
|CAST((0.06 + 0.01) AS DECIMAL(18,2))|
+------------------------------------+
|                                0.07|
+------------------------------------+

DataFusion

❯ select cast(0.06+0.01 as decimal(18,2));
+-------------------------------+
| Float64(0.06) + Float64(0.01) |
+-------------------------------+
| 0.06                          |
+-------------------------------+

To Reproduce
See above

Expected behavior

Additional context
Discovered as part of #4024

@andygrove andygrove added the bug Something isn't working label Nov 1, 2022
@andygrove andygrove added this to the 14.0.0 milestone Nov 1, 2022
@andygrove andygrove changed the title Inconsistent behavior with literal value versus expression in filter Round error when casting float to decimal Nov 2, 2022
@andygrove
Copy link
Member Author

filed related issue in arrow-rs: apache/arrow-rs#2997

@tustvold
Copy link
Contributor

Fixed by #4199

❯ select cast(0.06+0.01 as decimal(18,2));
+-------------------------------+
| Float64(0.06) + Float64(0.01) |
+-------------------------------+
| 0.07                          |
+-------------------------------+
1 row in set. Query took 0.008 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants