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

Function test_slice_union

arrow-array/src/array/union_array.rs:1655–1681  ·  view source on GitHub ↗
(record_batch_slice: RecordBatch)

Source from the content-addressed store, hash-verified

1653 }
1654
1655 fn test_slice_union(record_batch_slice: RecordBatch) {
1656 let union_slice = record_batch_slice
1657 .column(0)
1658 .as_any()
1659 .downcast_ref::<UnionArray>()
1660 .unwrap();
1661
1662 assert_eq!(union_slice.type_id(0), 0);
1663 assert_eq!(union_slice.type_id(1), 1);
1664 assert_eq!(union_slice.type_id(2), 1);
1665
1666 let slot = union_slice.value(0);
1667 let array = slot.as_primitive::<Int32Type>();
1668 assert_eq!(array.len(), 1);
1669 assert!(array.is_null(0));
1670
1671 let slot = union_slice.value(1);
1672 let array = slot.as_primitive::<Float64Type>();
1673 assert_eq!(array.len(), 1);
1674 assert!(array.is_valid(0));
1675 assert_eq!(array.value(0), 3.0);
1676
1677 let slot = union_slice.value(2);
1678 let array = slot.as_primitive::<Float64Type>();
1679 assert_eq!(array.len(), 1);
1680 assert!(array.is_null(0));
1681 }
1682
1683 // Sparse Union
1684 let builder = UnionBuilder::new_sparse();

Callers 1

slice_union_arrayFunction · 0.85

Calls 3

as_anyMethod · 0.45
columnMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected