Skip to content

Commit

Permalink
Fix NullBufferBuilder::new_from_buffer wrong size assertion (#5489)
Browse files Browse the repository at this point in the history
* Fix NullBufferBuilder::new_from_buffer wrong size assertion

* Add test
  • Loading branch information
Kikkon committed Mar 10, 2024
1 parent 82fc0df commit 94da02f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions arrow-array/src/array/primitive_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2564,4 +2564,21 @@ mod tests {
let debug_str = format!("{:?}", array);
assert_eq!("PrimitiveArray<Time64(Microsecond)>\n[\n Cast error: Failed to convert -1 to temporal for Time64(Microsecond),\n 00:00:00,\n 23:59:59,\n Cast error: Failed to convert 86400000000 to temporal for Time64(Microsecond),\n Cast error: Failed to convert 86401000000 to temporal for Time64(Microsecond),\n null,\n]", debug_str);
}

#[test]
fn test_primitive_with_nulls_into_builder() {
let array: Int32Array = vec![
Some(1),
None,
Some(3),
Some(4),
None,
Some(7),
None,
Some(8),
]
.into_iter()
.collect();
let _ = array.into_builder();
}
}
2 changes: 1 addition & 1 deletion arrow-buffer/src/builder/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl NullBufferBuilder {
pub fn new_from_buffer(buffer: MutableBuffer, len: usize) -> Self {
let capacity = buffer.len() * 8;

assert!(len < capacity);
assert!(len <= capacity);

let bitmap_builder = Some(BooleanBufferBuilder::new_from_buffer(buffer, len));
Self {
Expand Down

0 comments on commit 94da02f

Please sign in to comment.