-
Notifications
You must be signed in to change notification settings - Fork 834
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
Cast int to decimal has an unexpected result #5793
Comments
I notice there is
|
There is a good chance the conversion does not work correctly for negative scales |
Hi, I think I've found the cause. Would like to take this up for a fix. |
Sure |
Hi @tustvold @jayzhan211 I've made the changes. Please review them. |
I am depressed about the large review backlog in this crate. We are looking for more help from the community reviewing PRs -- see #6418 for more |
It's not clear to me that the original behavior is bad. It seems like it is casting numerically. That is, It seems like what you are suggesting is casting uses the integer as the internal integer representation and then attaches the scale blindly. So Is there a SQL system that sets some precedent for how this work? For example, how does postgres do this? |
To be honest there was little reference on its behaviour, including on the internet. And naturally I'd have asked how to go about this, but then I read the documentation which said negative precision is just the padding of zeroes to the right. |
The proposal is based on the arrow's document so it might not be correct / expected https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html#variant.Decimal128
Postgres
I think we might need to fix the doc |
I was just about to post this too. 😅 This also means that this issue can be closed, and the PR will be no longer required. |
Postgres documents the behavior as below:
Check out the docs. |
@jayzhan211 if you concur let's close the ticket |
Thank you for the research @ByteBaker and @wjones127 |
Sure, we just need to fix the document to be consistent with the postgres's one |
Describe the bug
To Reproduce
Expected behavior
I think we should get
Additional context
https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html#variant.Decimal128
The text was updated successfully, but these errors were encountered: