You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alexwilcoxson-rel (via GitHub)" <gi...@apache.org> on 2024/09/18 19:58:18 UTC
[PR] fix: don't panic in IPC reader if struct child arrays have different … [arrow-rs]
alexwilcoxson-rel opened a new pull request, #6417:
URL: https://github.com/apache/arrow-rs/pull/6417
…lengths
# Which issue does this PR close?
Closes #6416
# Rationale for this change
While we don't expect to receive invalid IPC data via flight. We would like to avoid panics if possible.
# What changes are included in this PR?
Use StructArray::try_new vs StructArray::from in ipc reader. StructArray::from impls use StructArray::new. new calls try_new but unwraps.
# 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: don't panic in IPC reader if struct child arrays have different … [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6417:
URL: https://github.com/apache/arrow-rs/pull/6417#discussion_r1768333832
##########
arrow-ipc/src/reader.rs:
##########
@@ -2235,4 +2237,50 @@ mod tests {
assert_eq!(batch, roundtrip_batch);
}
+
+ #[test]
+ fn test_invalid_struct_array_ipc_read_errors() {
Review Comment:
I verified that this test panic's without the code changes in this PR, as expected
```
` value: InvalidArgumentError("Incorrect array length for StructArray field \"b\", expected 4 got 3")
stack backtrace:
0: rust_begin_unwind
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
1: core::panicking::panic_fmt
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
2: core::result::unwrap_failed
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/result.rs:1679:5
3: core::result::Result<T,E>::unwrap
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/result.rs:1102:23
4: arrow_array::array::struct_array::StructArray::new
at /Users/andrewlamb/Software/arrow-rs/arrow-array/src/array/struct_array.rs:90:9
5: <arrow_array::array::struct_array::StructArray as core::convert::From<alloc::vec::Vec<(alloc::sync::Arc<arrow_schema::field::Field>,alloc::sync::Arc<dyn arrow_array::array::Array>)>>>::from
at /Users/andrewlamb/Software/arrow-rs/arrow-array/src/array/struct_array.rs:401:9
6: arrow_ipc::reader::create_array
at ./src/reader.rs:167:17
7: arrow_ipc::reader::read_record_batch_impl
```
--
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: don't panic in IPC reader if struct child arrays have different … [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6417:
URL: https://github.com/apache/arrow-rs/pull/6417#discussion_r1765667998
##########
arrow-ipc/src/reader.rs:
##########
@@ -31,7 +31,9 @@ use std::io::{BufReader, Read, Seek, SeekFrom};
use std::sync::Arc;
use arrow_array::*;
-use arrow_buffer::{ArrowNativeType, BooleanBuffer, Buffer, MutableBuffer, ScalarBuffer};
+use arrow_buffer::{
Review Comment:
Can we please get a test for this fix so that we don't break it again during some future refactoring?
--
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: don't panic in IPC reader if struct child arrays have different … [arrow-rs]
Posted by "alexwilcoxson-rel (via GitHub)" <gi...@apache.org>.
alexwilcoxson-rel commented on code in PR #6417:
URL: https://github.com/apache/arrow-rs/pull/6417#discussion_r1765756374
##########
arrow-ipc/src/reader.rs:
##########
@@ -31,7 +31,9 @@ use std::io::{BufReader, Read, Seek, SeekFrom};
use std::sync::Arc;
use arrow_array::*;
-use arrow_buffer::{ArrowNativeType, BooleanBuffer, Buffer, MutableBuffer, ScalarBuffer};
+use arrow_buffer::{
Review Comment:
just added, was able to write the invalid array to ipc buffer using ArrayDataBuilder::build_unchecked
--
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: don't panic in IPC reader if struct child arrays have different … [arrow-rs]
Posted by "alexwilcoxson-rel (via GitHub)" <gi...@apache.org>.
alexwilcoxson-rel commented on PR #6417:
URL: https://github.com/apache/arrow-rs/pull/6417#issuecomment-2359302768
Any advice on how to generate this type of invalid batch with arrow-rs for testing?
--
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: don't panic in IPC reader if struct child arrays have different … [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #6417:
URL: https://github.com/apache/arrow-rs/pull/6417
--
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