Skip to content

Commit 94da02f

Browse files
authored
Fix NullBufferBuilder::new_from_buffer wrong size assertion (#5489)
* Fix NullBufferBuilder::new_from_buffer wrong size assertion * Add test
1 parent 82fc0df commit 94da02f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

arrow-array/src/array/primitive_array.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,4 +2564,21 @@ mod tests {
25642564
let debug_str = format!("{:?}", array);
25652565
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);
25662566
}
2567+
2568+
#[test]
2569+
fn test_primitive_with_nulls_into_builder() {
2570+
let array: Int32Array = vec![
2571+
Some(1),
2572+
None,
2573+
Some(3),
2574+
Some(4),
2575+
None,
2576+
Some(7),
2577+
None,
2578+
Some(8),
2579+
]
2580+
.into_iter()
2581+
.collect();
2582+
let _ = array.into_builder();
2583+
}
25672584
}

arrow-buffer/src/builder/null.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl NullBufferBuilder {
5454
pub fn new_from_buffer(buffer: MutableBuffer, len: usize) -> Self {
5555
let capacity = buffer.len() * 8;
5656

57-
assert!(len < capacity);
57+
assert!(len <= capacity);
5858

5959
let bitmap_builder = Some(BooleanBufferBuilder::new_from_buffer(buffer, len));
6060
Self {

0 commit comments

Comments
 (0)