Skip to content

docs: clarify decimal negative scale behavior#10304

Merged
Jefffrey merged 1 commit into
apache:mainfrom
ByteBaker:main
Jul 15, 2026
Merged

docs: clarify decimal negative scale behavior#10304
Jefffrey merged 1 commit into
apache:mainfrom
ByteBaker:main

Conversation

@ByteBaker

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

The issue was discussed in the PR and issue mentioned above and it was agreed here that we should update the docs. We just never got to actually doing it.

What changes are included in this PR?

Updates the Decimal32, Decimal64, Decimal128, and Decimal256 docs to explain that negative scale rounds values to the left of the decimal point, and that precision is the maximum number of non-rounded digits.

Also adds an example showing how a value is rounded and represented internally.

Are these changes tested?

Ran fmt. Doc only changes, no other test required.
No runtime tests were added because this is a documentation-only change.

Are there any user-facing changes?

Documentation only. No API or behavior changes.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jul 8, 2026
@ByteBaker

Copy link
Copy Markdown
Contributor Author

@jayzhan211 @alamb @wjones127 Please accept my apologies. We agreed the last time while closing #5793 that we should fix the docs, and I was supposed to do it. Life happened in the meantime and I totally forgot about it. 😅

This morning I found it in my old TODOs and decided to do it. Lemme know what y'all think of the changes.

Comment thread arrow-schema/src/datatype.rs Outdated
Comment on lines +368 to +369
/// For example, with precision 2 and scale -3, the value 12345 is
/// rounded to 12000 and represented as the stored integer 12.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i find it a little confusing that we talk about how 12345 is converted to a negative scale decimal here, instead of in cast kernels 🤔

imo at this level all we care about is explaining how values already stored as decimals are represented and what they actually represent, aka we can say a value of 12 but with -3 scale is equivalent to 12000

(i skimmed the linked discussion so maybe this was already discussed 😅)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it. TBH I find explaining this somewhat confusing by nature. 😬

But please see if the newer one is more clearer.

@Jefffrey Jefffrey added the documentation Improvements or additions to documentation label Jul 15, 2026
@Jefffrey
Jefffrey merged commit 3954050 into apache:main Jul 15, 2026
30 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @ByteBaker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants