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

   ### Describe the bug
   
   Since #10945, `take_record_batch` builds its result with 
`RecordBatch::new_unchecked` 
([take.rs](https://github.com/apache/arrow-rs/blob/01a9917658fecd639991e92a5a5810be710b539c/arrow-select/src/take.rs#L1724)),
 which skips the nullability check of `RecordBatch::try_new`. No release 
contains #10945.
   
   ### To Reproduce
   
   ```rust
   use std::sync::Arc;
   
   use arrow_array::{Array, ArrayRef, Int32Array, RecordBatch};
   use arrow_schema::{DataType, Field, Schema};
   use arrow_select::take::take_record_batch;
   
   fn main() {
       let schema = Arc::new(Schema::new(vec![Field::new("a", DataType::Int32, 
false)]));
       let batch = RecordBatch::try_new(schema, 
vec![Arc::new(Int32Array::from(vec![1, 2])) as ArrayRef]).unwrap();
   
       let out = take_record_batch(&batch, &Int32Array::from(vec![Some(0), 
None])).unwrap();
       println!("{}", out.column(0).null_count()); // 1, in the non-nullable 
field "a"
       println!("{:?}", RecordBatch::try_new(out.schema(), 
out.columns().to_vec()).err());
       // Some(InvalidArgumentError("Column 'a' is declared as non-nullable but 
contains null values"))
   }
   ```
   
   ### Expected behavior
   
   An error, as 60.0.0 returns.
   
   ### Additional context
   
   #10945 also lets `take_record_batch` read out of bounds, filed as #TBD.
   
   Found with property-based tests that build arrays in every physical layout 
the Arrow format allows, on `main` at `01a991765`.
   


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