kawadakk opened a new issue, #6538:
URL: https://github.com/apache/arrow-rs/issues/6538

   **Describe the bug**
   `ListArray::try_new()` uses `Array::is_nullable()` to check the presence of 
null values if `field` is not marked as nullable.
   
<https://github.com/apache/arrow-rs/blob/5508978a3c5c4eb65ef6410e097887a8adaba38a/arrow-array/src/array/list_array.rs#L191-L197>
   
   While this works for most types, this can cause a false positive for 
`DictionaryArray` and `UnionArray` because `Array::is_nullable()` is allowed to 
return `true` if it's expensive to prove the absence of logical nulls.
   
   
<https://github.com/apache/arrow-rs/blob/5508978a3c5c4eb65ef6410e097887a8adaba38a/arrow-array/src/array/mod.rs#L287-L291>
   
   **To Reproduce**
   
   ```rust
   let offsets = OffsetBuffer::new(vec![0, 1, 4, 5].into());
   let mut builder = UnionBuilder::new_dense();
   builder.append::<Int32Type>("a", 1).unwrap();
   builder.append::<Int32Type>("b", 2).unwrap();
   builder.append::<Int32Type>("b", 3).unwrap();
   builder.append::<Int32Type>("a", 4).unwrap();
   builder.append::<Int32Type>("a", 5).unwrap();
   let values = builder.build().unwrap();
   let field = Arc::new(Field::new("element", values.data_type().clone(), 
false));
   ListArray::new(field.clone(), offsets, Arc::new(values), None);
   ```
   
   This produces:
   
   ```
   thread 'foo' panicked at foo.rs:10:46:
   called `Result::unwrap()` on an `Err` value: 
InvalidArgumentError("Non-nullable field of ListArray \"element\" cannot 
contain nulls")
   ```
   
   **Expected behavior**
   Successful execution
   
   **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]

Reply via email to