-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Dividing decimal type gives wrong error: "170141183460469231731687303715884105727 is too large to store in a Decimal128 #3498
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
Comments
I'm trying to learn the decimal implementation details, let me take a shot at this. |
FWIW @kmitchener -- I would love to move the decimal compute kernels to arrow-rs (and out of datafusion). I think they were originally implemented in datafusion for convenience as we (well mostly @liukun4515 ) worked to do the initial implementation I think moving them now would be appropriate (especially if we could add them to the various |
Yeah, I see TODOs sprinkled all over about moving it to arrow-rs. :) Makes complete sense, but I think I'm not up to such a huge task yet. However, I think I can do some bug-fixing and add tests to DF while I'm learning about this implementation, then maybe move, or help move the implementation over to arrow-rs after I have a better idea what's going on. |
Yes, I think it's time to move the operation about the decimal to the arrow-rs kernel. I will do this in the next sprint. I think we may meet some issue about the decimal type in the arrow-rs talked I think we can resolve them. |
I think this bug is caused by using the f32 or f64 to do the Because the intermediate result will be overflow when do the agg. I will try to do investigation and to resolve them, and find the reasonable behavior. I have listed a issue to collect the issue about decimal and TODO work. |
Sorry @liukun4515 -- I didn't see your comment before I merged #3517 -- I am happy to back it out or make other changes if needed. |
This is great news -- thanks @liukun4515 It may take some time to get the kernels into arrow, but I think the process will likely work out some of the corner cases we have left in datafusion for a while |
don't need to back it out. |
Describe the bug
Dividing by Decimal value by zero results in
cd datafusion-cli cargo run
To Reproduce
See above (divide a decimal number by zero)
Expected behavior
I expect an
DivideByZero
error:Additional context
Found while working on #3483
I am pretty sure the problem is in
Specifically, using floating point math to divide two floats and then casting to an int128 is where the
170141183460469231731687303715884105727
value comes fromhttps://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b5949eb324d9828a802aa11b4fa9d029
FYI @liukun4515
The text was updated successfully, but these errors were encountered: