tustvold commented on code in PR #2083:
URL: https://github.com/apache/arrow-rs/pull/2083#discussion_r922407674
##########
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:
There is currently an odd hack in Array::slice for StructArray that pushes
down the offset to the child arrays. You will need to manually construct the
ArrayData for the StructArray in order to properly test the case of a
StructArray with a non-zero offset. See
https://github.com/apache/arrow-rs/issues/1750 for more information
--
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]