Skip to content

Fix precision loss for fixed-point values with non-zero scale - #1835

Merged
sfc-gh-pfus merged 2 commits into
snowflakedb:masterfrom
tanner-lai:fix-decimal-scale-precision
Aug 18, 2026
Merged

sfc-gh-pfus merged 2 commits into
snowflakedb:masterfrom
tanner-lai:fix-decimal-scale-precision

Conversation

@tanner-lai

@tanner-lai tanner-lai commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Both non-higher-precision conversion paths for fixed-point values routed the exact unscaled integer through a binary float before formatting it, silently rounding values carrying more significant digits than the float's mantissa could hold. arrowDecimal128ToValue divided using a 64-bit big.Float, so NUMBER(20,10) holding 1234567890.1234567890 returned 1234567890.1234567889; arrowIntToValue divided as float64, so NUMBER(18,4) holding 12345678901234.5678 returned 12345678901234.5684. Both now format from the unscaled integer via decimal128.ToString, as the scale == 0 branch already did. The higherPrecision paths still return *big.Float and are left unchanged, since that return type is approximate by contract.

Checklist

  • Added proper logging (if possible)
  • Created tests which fail without the change (if possible)
  • Extended the README / documentation, if necessary

@tanner-lai
tanner-lai requested a review from a team as a code owner August 6, 2026 19:20
@sfc-gh-pfus

Copy link
Copy Markdown
Collaborator

Hi @tanner-lai ! Thanks for your contribution, it seems correct. Can you add a changelog.md entry?

Both non-higher-precision conversion paths for fixed-point values routed the
exact unscaled integer through a binary float before formatting it, silently
rounding values carrying more significant digits than the float's mantissa could
hold. arrowDecimal128ToValue divided using a 64-bit big.Float, so NUMBER(20,10)
holding 1234567890.1234567890 returned 1234567890.1234567889; arrowIntToValue
divided as float64, so NUMBER(18,4) holding 12345678901234.5678 returned
12345678901234.5684. Both now format from the unscaled integer via
decimal128.ToString, as the scale == 0 branch already did. The higherPrecision
paths still return *big.Float and are left unchanged, since that return type is
approximate by contract.
@tanner-lai
tanner-lai force-pushed the fix-decimal-scale-precision branch from 0e7dd4e to 9dec3ca Compare August 7, 2026 14:11
@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@tanner-lai

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@tanner-lai

Copy link
Copy Markdown
Contributor Author

Hi @tanner-lai ! Thanks for your contribution, it seems correct. Can you add a changelog.md entry?

Just added an entry, thanks!

@tanner-lai

Copy link
Copy Markdown
Contributor Author

@sfc-gh-pfus Is there anything left to address? Do you guys have a practice to older versions/do I need to make those PRs as well?

@sfc-gh-pfus

Copy link
Copy Markdown
Collaborator

@tanner-lai sorry, I was on holiday. I'll get to your PR this week!

@sfc-gh-pfus
sfc-gh-pfus merged commit 60a46fb into snowflakedb:master Aug 18, 2026
56 of 59 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants