()
| 759 | /// validates that the in-memory representation follows [the spec](https://arrow.apache.org/docs/format/Columnar.html#struct-layout) |
| 760 | #[test] |
| 761 | fn test_struct_array_from_vec() { |
| 762 | let strings: ArrayRef = Arc::new(StringArray::from(vec![ |
| 763 | Some("joe"), |
| 764 | None, |
| 765 | None, |
| 766 | Some("mark"), |
| 767 | ])); |
| 768 | let ints: ArrayRef = Arc::new(Int32Array::from(vec![Some(1), Some(2), None, Some(4)])); |
| 769 | |
| 770 | let arr = |
| 771 | StructArray::try_from(vec![("f1", strings.clone()), ("f2", ints.clone())]).unwrap(); |
| 772 | |
| 773 | let struct_data = arr.into_data(); |
| 774 | assert_eq!(4, struct_data.len()); |
| 775 | assert_eq!(0, struct_data.null_count()); |
| 776 | |
| 777 | let expected_string_data = ArrayData::builder(DataType::Utf8) |
| 778 | .len(4) |
| 779 | .null_bit_buffer(Some(Buffer::from(&[9_u8]))) |
| 780 | .add_buffer(Buffer::from([0, 3, 3, 3, 7].to_byte_slice())) |
| 781 | .add_buffer(Buffer::from(b"joemark")) |
| 782 | .build() |
| 783 | .unwrap(); |
| 784 | |
| 785 | let expected_int_data = ArrayData::builder(DataType::Int32) |
| 786 | .len(4) |
| 787 | .null_bit_buffer(Some(Buffer::from(&[11_u8]))) |
| 788 | .add_buffer(Buffer::from([1, 2, 0, 4].to_byte_slice())) |
| 789 | .build() |
| 790 | .unwrap(); |
| 791 | |
| 792 | assert_eq!(expected_string_data, struct_data.child_data()[0]); |
| 793 | assert_eq!(expected_int_data, struct_data.child_data()[1]); |
| 794 | } |
| 795 | |
| 796 | #[test] |
| 797 | fn test_struct_array_from_vec_error() { |
nothing calls this directly
no test coverage detected