Skip to content
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

decimal division gives wrong answer #3521

Open
Tracked by #3523
kmitchener opened this issue Sep 16, 2022 · 0 comments
Open
Tracked by #3523

decimal division gives wrong answer #3521

kmitchener opened this issue Sep 16, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@kmitchener
Copy link
Contributor

kmitchener commented Sep 16, 2022

Describe the bug
A clear and concise description of what the bug is.

select 10.1::decimal(5,1)/a from (values (1),(null)) as t(a);
+---------------------------+
| Float64(10.1) / t.a       |
+---------------------------+
| 10.0999999999999997902848 |
|                           |
+---------------------------+
2 rows in set. Query took 0.005 seconds.

Note also that the return type is correctly Decimal, it's just giving wrong results because it's using float internally to do the division.

select arrow_typeof(10.1::decimal(5,1)/a) from (values (1),(null)) as t(a);
+----------------------------------+
| arrowtypeof(Float64(10.1) / t.a) |
+----------------------------------+
| Decimal128(26, 22)               |
| Decimal128(26, 22)               |
+----------------------------------+
2 rows in set. Query took 0.010 seconds.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

This should return 10.1 and null.

Additional context
Add any other context about the problem here.

@kmitchener kmitchener added the bug Something isn't working label Sep 16, 2022
@andygrove andygrove modified the milestone: 14.0.0 Oct 30, 2022
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

Successfully merging a pull request may close this issue.

2 participants