jorgecarleitao commented on a change in pull request #9469:
URL: https://github.com/apache/arrow/pull/9469#discussion_r574717129



##########
File path: rust/arrow/src/array/array.rs
##########
@@ -409,4 +578,42 @@ mod tests {
         assert_eq!(a.len(), 0);
         assert_eq!(a.value_offsets()[0], 0i32);
     }
+
+    #[test]
+    fn test_null_boolean() {
+        let array = new_array_with_nulls(&DataType::Boolean, 9);
+        let a = array.as_any().downcast_ref::<BooleanArray>().unwrap();
+        assert_eq!(a.len(), 9);
+        for i in 0..9 {
+            assert!(a.is_null(i));
+        }
+    }
+
+    #[test]
+    fn test_null_primitive() {
+        let array = new_array_with_nulls(&DataType::Int32, 9);
+        let a = array.as_any().downcast_ref::<Int32Array>().unwrap();
+        assert_eq!(a.len(), 9);
+        for i in 0..9 {
+            assert!(a.is_null(i));
+        }
+    }
+
+    #[test]
+    fn test_null_variable_sized() {
+        let array = new_array_with_nulls(&DataType::Utf8, 9);
+        let a = array.as_any().downcast_ref::<StringArray>().unwrap();
+        assert_eq!(a.len(), 9);
+        assert_eq!(a.value_offsets()[9], 0i32);
+    }
+
+    #[test]
+    fn test_null_list_primitive() {
+        let data_type =
+            DataType::List(Box::new(Field::new("item", DataType::Int32, 
true)));

Review comment:
       yeah, that hole exists in so many places, unfortunately. Since 
`ArrayData` has a `null_count`, we have been relying on it for this.
   
   Technically, this goes back to the issue that we are not performing any 
validation whether the datatype is consistent with the array's content. :(




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to