viirya commented on code in PR #2083:
URL: https://github.com/apache/arrow-rs/pull/2083#discussion_r922482702
##########
arrow/src/ipc/writer.rs:
##########
@@ -1784,4 +1784,52 @@ mod tests {
assert_eq!(record_batch_slice, deserialized_batch);
}
+
+ #[test]
+ fn truncate_ipc_struct_array() {
+ fn create_batch() -> RecordBatch {
+ let strings: StringArray = [Some("foo"), None, Some("bar"),
Some("baz")]
+ .into_iter()
+ .collect();
+ let ints: Int32Array =
+ [Some(0), Some(2), None, Some(1)].into_iter().collect();
+
+ let struct_array = StructArray::from(vec![
+ (
+ Field::new("s", DataType::Utf8, true),
+ Arc::new(strings) as ArrayRef,
+ ),
+ (
+ Field::new("c", DataType::Int32, false),
+ Arc::new(ints) as ArrayRef,
+ ),
+ ]);
+
+ let schema = Schema::new(vec![Field::new(
+ "struct_array",
+ struct_array.data_type().clone(),
+ true,
+ )]);
+
+ RecordBatch::try_new(Arc::new(schema),
vec![Arc::new(struct_array)]).unwrap()
+ }
+
+ let record_batch = create_batch();
+ let record_batch_slice = record_batch.slice(1, 2);
Review Comment:
I see. You are basically concerned about "This makes it unclear if an offset
should or should not be applied to the child_array". As the updated offset is
applied on both parent array and child arrays, it is somehow obscure that
whether we should take parent's offset when working with child arrays.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]