You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "theirix (via GitHub)" <gi...@apache.org> on 2026/05/31 17:34:37 UTC
[PR] fix: handle negative size of FixedSizeBinary [arrow-rs]
theirix opened a new pull request, #10042:
URL: https://github.com/apache/arrow-rs/pull/10042
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
-->
- Closes #10033.
# Rationale for this change
Related to #22297, where using `FixedSizeBinary(-N)` caused failures. It will fail with a different error, but still panic.
It could be a good idea to introduce `try_new_null` to carry an error gracefully - thoughts?
# What changes are included in this PR?
- Return a `Result` on negative byte width when possible
- Panic explicitly with a proper error message otherwise
- Avoid silent overflow with a direct `len as usize` cast
# Are these changes tested?
- Tests are passing
# Are there any user-facing changes?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: better error handling for negative size of FixedSizeBinary [arrow-rs]
Posted by "theirix (via GitHub)" <gi...@apache.org>.
theirix commented on PR #10042:
URL: https://github.com/apache/arrow-rs/pull/10042#issuecomment-4595410920
> Do we have a test case from the original issue? I think DataFusion was calling a parse code path in arrow-rs, so maybe look to add the test case there? (parsing a datatype from string, I mean)
Not anything I am aware of- can introduce one later. Anyway, writing such a test will be much easier if we have `ArrayData::try_new_null` - should we? `ArrayData::new_null` already has a few unwraps inside
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: better error handling for negative size of FixedSizeBinary [arrow-rs]
Posted by "theirix (via GitHub)" <gi...@apache.org>.
theirix commented on code in PR #10042:
URL: https://github.com/apache/arrow-rs/pull/10042#discussion_r3337145228
##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -375,6 +375,12 @@ impl<'a> Parser<'a> {
fn parse_fixed_size_binary(&mut self) -> ArrowResult<DataType> {
self.expect_token(Token::LParen)?;
let length = self.parse_i32("FixedSizeBinary")?;
+ if length < 0 {
Review Comment:
The format doesn't tell anything about it. The C++ implementation [allows zero-width buffer](https://github.com/apache/arrow/blob/e2b44378edf0ccceda07e8a6823890bd4ecc1952/cpp/src/arrow/type.cc#L1117). Fixed an error message
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: better error handling for negative size of FixedSizeBinary [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10042:
URL: https://github.com/apache/arrow-rs/pull/10042#discussion_r3337073538
##########
arrow-schema/src/datatype_parse.rs:
##########
@@ -375,6 +375,12 @@ impl<'a> Parser<'a> {
fn parse_fixed_size_binary(&mut self) -> ArrowResult<DataType> {
self.expect_token(Token::LParen)?;
let length = self.parse_i32("FixedSizeBinary")?;
+ if length < 0 {
Review Comment:
Is FixedSizeBinary(0) allowed? I think this check only verifies >= 0 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: better error handling for negative size of FixedSizeBinary [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10042:
URL: https://github.com/apache/arrow-rs/pull/10042#issuecomment-4595534764
Maybe @Jefffrey was talking about
https://github.com/apache/arrow-rs/blob/f1ef71aa5aab3d5f3e3ff46f63dd198cf5da7b38/arrow-schema/src/datatype.rs#L495-L507
In the sense that it perhaps more likely for someone to be able to feed negative numbers in via SQL than via Rust APIs.
So in this case case, `arrow_cast(..)` calls `DataType::try_from_str` which could potentially validate the `DataType` before return
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: better error handling for negative size of FixedSizeBinary [arrow-rs]
Posted by "theirix (via GitHub)" <gi...@apache.org>.
theirix commented on PR #10042:
URL: https://github.com/apache/arrow-rs/pull/10042#issuecomment-4595863983
Thank you for pointing it out. I've added a check into the parser and a test for it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: better error handling for negative size of FixedSizeBinary [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #10042:
URL: https://github.com/apache/arrow-rs/pull/10042
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: better error handling for negative size of FixedSizeBinary [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10042:
URL: https://github.com/apache/arrow-rs/pull/10042#issuecomment-4603638449
Thank you @theirix and @Jefffrey
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org