MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_flatten_sliced_struct

Function test_flatten_sliced_struct

arrow-array/src/array/struct_array.rs:1085–1101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1083
1084 #[test]
1085 fn test_flatten_sliced_struct() {
1086 let child = Arc::new(Int32Array::from(vec![1, 2, 3, 4])) as ArrayRef;
1087 let struct_nulls = NullBuffer::new(BooleanBuffer::from(vec![true, false, true, false]));
1088 let sa = StructArray::new(
1089 Fields::from(vec![Field::new("a", DataType::Int32, false)]),
1090 vec![child],
1091 Some(struct_nulls),
1092 );
1093 let sliced = sa.slice(1, 2);
1094
1095 let (fields, columns) = sliced.flatten();
1096
1097 assert!(fields[0].is_nullable());
1098 assert_eq!(columns[0].len(), 2);
1099 assert!(columns[0].is_null(0));
1100 assert!(columns[0].is_valid(1));
1101 }
1102
1103 #[test]
1104 fn test_flatten_multiple_children() {

Callers

nothing calls this directly

Calls 2

flattenMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected