timmyb32r commented on code in PR #12256:
URL: https://github.com/apache/arrow-rs/pull/12256#discussion_r4627476581


##########
arrow-schema/src/schema.rs:
##########
@@ -908,6 +906,46 @@ mod tests {
         assert_eq!(schema, expected);
     }
 
+    #[test]
+    fn normalize_inherits_parent_nullability() {
+        for parent_nullable in [false, true] {
+            for middle_nullable in [false, true] {
+                for child_nullable in [false, true] {
+                    for data_type in [DataType::Int32, 
DataType::new_list(DataType::Int32, false)] {
+                        let child = Field::new("child", data_type.clone(), 
child_nullable);
+                        let middle =
+                            Field::new_struct("middle", vec![child.clone()], 
middle_nullable);
+                        let sibling = Field::new("sibling", DataType::Int32, 
false);
+                        let schema = Schema::new(vec![
+                            Field::new_struct("parent", vec![middle], 
parent_nullable),
+                            sibling.clone(),
+                        ]);
+                        for max_level in [None, Some(0), Some(1), Some(2)] {
+                            let expected_field = if max_level == Some(1) {

Review Comment:
   This test builds next structure:
   
   ```
   parent - is a Field::new_struct(vec<middle>)
   middle - is a Field::new_struct(vec<child>)
   child - is a Field::new('data_type')
   ```
   
   then
   ```
   if schema.normalize with max_level=0 and None -- it means both struct level 
unwrapped and lead to 'child' field (not struct)
   if schema.normalize with max_level=1 -- we've got 
Field::new_struct(vec<child>)
   if schema.normalize with max_level=2 -- we've got Field::new('data_type')
   ```
   
   so, when max_level in (None, 0, 2) - then we have 'field', when max_level=1 
- then we have 'struct'



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

Reply via email to