Skip to content
New issue

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

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

Already on GitHub? # to your account

Casting Decimal128 to Decimal128 with smaller precision produces incorrect results in some cases #6833

Closed
andygrove opened this issue Dec 3, 2024 · 2 comments · Fixed by #6836
Labels
arrow Changes to the arrow crate bug

Comments

@andygrove
Copy link
Member

andygrove commented Dec 3, 2024

Describe the bug

If I try and cast floating-point value 12345.67 to decimal(6,2) then I get an error, as expected:

"1234567 is too large to store in a Decimal128 of precision 6. Max is 999999"

However, if I try and cast a decimal(24,2) value of 12345.67 to decimal(6,2) then I do not get an error but instead have an invalid decimal value.

PrimitiveArray<Decimal128(6, 2)>
[
    1234567,
]

If I then convert this decimal to a string, it produces 1234.56 instead of 12345.67

StringArray
[
  "1234.56",
]

To Reproduce

Expected behavior

Additional context

This is the root cause of apache/datafusion#13492

@andygrove andygrove added the bug label Dec 3, 2024
@himadripal
Copy link
Contributor

Working on it

@alamb
Copy link
Contributor

alamb commented Dec 17, 2024

label_issue.py automatically added labels {'arrow'} from #6850

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
arrow Changes to the arrow crate bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants