Skip to content

GH-53288: [C++][Python] Preserve full coefficients in safe Decimal32 casts - #55246

Closed
mikamikasuki wants to merge 1 commit into
apache:mainfrom
mikamikasuki:fix/53288-safe-decimal32-casts
Closed

mikamikasuki wants to merge 1 commit into
apache:mainfrom
mikamikasuki:fix/53288-safe-decimal32-casts

Conversation

@mikamikasuki

Copy link
Copy Markdown

Rationale for this change

Safe decimal casts to Decimal32 can silently change values or reject exact conversions because the input coefficient is narrowed before rescaling and precision checks.

What changes are included in this PR?

Keep wider input decimals at their source width during safe rescaling, then narrow to Decimal32 only after the target precision check succeeds.

Fixes #53288.

Are these changes tested?

Added regression cases for overflow, negative-scale exact rescaling, and fractional-scale exact rescaling. The regression fails with the previous conversion path and passes with this change. The full arrow-compute-scalar-cast-test executable passes (108 tests).

Are there any user-facing changes?

Safe casts now return the correct value or an overflow error. No public API changes.

This PR contains a "Critical Fix". Safe casts could previously return an incorrect decimal value or reject an exact conversion.

Was AI used for this PR?

OpenAI Codex assisted with investigation, implementation, regression-test development, and review. The new tests were run against current main (2c800e6) before and after the fix.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@github-actions

Copy link
Copy Markdown

❌ GitHub issue #53288 could not be retrieved.

@github-actions

Copy link
Copy Markdown

Thanks for opening a pull request!

This pull request has been automatically closed because you currently have 4 open pull requests, which is more than the limit of 3.

Due to the increase in pull requests opened by AI bots, and in order to keep the review queue manageable, Apache Arrow limits contributors without repository access to at most 3 concurrently open pull requests. This helps make sure each pull request gets the attention it needs and that work in progress does not go stale.

Once one of your other open pull requests has been merged or closed, you are welcome to reopen this one.

See also:

@github-actions github-actions Bot closed this Oct 25, 2026
@github-actions github-actions Bot added the awaiting review Awaiting review label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review Awaiting review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant