kawadakk opened a new issue, #4600: URL: https://github.com/apache/arrow-rs/issues/4600
**Describe the bug** `new_null_array` generates a union array that fails validation by `ArrayData::validate_full`. **To Reproduce** Modify [`test_null_union`](https://github.com/apache/arrow-rs/blob/16744e5ac08d9ead6c51ff6e08d8b91e87460c52/arrow-array/src/array/mod.rs#L819-L845) as follows: ```rust #[test] fn test_null_union() { for mode in [UnionMode::Sparse, UnionMode::Dense] { let data_type = DataType::Union( UnionFields::new( vec![2, 1], vec![ Field::new("foo", DataType::Int32, true), Field::new("bar", DataType::Int64, true), ], ), mode, ); let array = new_null_array(&data_type, 4); let array = as_union_array(array.as_ref()); assert_eq!(array.len(), 4); assert_eq!(array.null_count(), 0); for i in 0..4 { let a = array.value(i); assert_eq!(a.len(), 1); assert_eq!(a.null_count(), 1); assert!(a.is_null(0)) } array.to_data().validate_full().unwrap(); // <---- new } } ``` This will fail with the following output: ``thread 'array::tests::test_null_union' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidArgumentError("Sparse union child array #1 has length smaller than expected for union array (0 < 4)")', arrow-array\src\array\mod.rs:852:45`` **Expected behavior** Producing a valid array **Additional context** <!-- Add any other context about the problem here. --> -- 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]
