(record_batch_slice: RecordBatch)
| 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(); |
no test coverage detected