Skip to content

fix: Reject empty strings when casting strings to decimal#10010

Open
neilconway wants to merge 1 commit into
apache:mainfrom
neilconway:neilc/fix-decimal-parse-empty-string
Open

fix: Reject empty strings when casting strings to decimal#10010
neilconway wants to merge 1 commit into
apache:mainfrom
neilconway:neilc/fix-decimal-parse-empty-string

Conversation

@neilconway
Copy link
Copy Markdown
Contributor

@neilconway neilconway commented May 23, 2026

Which issue does this PR close?

Rationale for this change

When casting string values to decimal, parse_string_to_decimal_native treated empty strings and whitespace-only strings as valid input, resulting in a decimal with a value of 0. This is inconsistent with parse_decimal and how parsing and string -> numeric casts work for floating point types: in all of those cases, empty strings and whitespace-only strings are rejected.

What changes are included in this PR?

  • Change parse_string_to_decimal_native to reject empty strings and whitespace-only strings
  • Add test coverage

Are these changes tested?

Yes, new tests added.

Are there any user-facing changes?

Yes, this changes the behavior of string -> decimal casts. The previous behavior is (IMO) clearly incorrect but it is possible that some user code relies upon it.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label May 23, 2026
@neilconway neilconway force-pushed the neilc/fix-decimal-parse-empty-string branch from 7ab35ab to 9dc7e20 Compare May 25, 2026 13:40
@neilconway
Copy link
Copy Markdown
Contributor Author

@Jefffrey If you have a moment, can you take a look?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

string -> decimal cast should not treat empty string as 0

1 participant