Skip to content

Commit

Permalink
Add test for creating FixedSizeBinaryArray::try_from_sparse_iter fail…
Browse files Browse the repository at this point in the history
…ed when given all Nones
  • Loading branch information
alamb committed Apr 12, 2022
1 parent 68038f5 commit c9eaa5b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion arrow/src/array/array_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,9 +1060,12 @@ impl Array for DecimalArray {

#[cfg(test)]
mod tests {
use std::sync::Arc;

use crate::{
array::{DecimalBuilder, LargeListArray, ListArray},
datatypes::Field,
datatypes::{Field, Schema},
record_batch::RecordBatch,
};

use super::*;
Expand Down Expand Up @@ -1739,4 +1742,23 @@ mod tests {
.validate_full()
.expect("All null array has valid array data");
}

#[test]
// Test for https://github.com/apache/arrow-rs/issues/1390
#[should_panic(
expected = "column types must match schema types, expected FixedSizeBinary(2) but found FixedSizeBinary(0) at column index 0."
)]
fn fixed_size_binary_array_all_null_in_batch_with_schema() {
let schema =
Schema::new(vec![Field::new("a", DataType::FixedSizeBinary(2), false)]);

let none_option: Option<[u8; 2]> = None;
let item = FixedSizeBinaryArray::try_from_sparse_iter(
vec![none_option, none_option, none_option].into_iter(),
)
.unwrap();

// Should not panic
RecordBatch::try_new(Arc::new(schema), vec![Arc::new(item)]).unwrap();
}
}

0 comments on commit c9eaa5b

Please sign in to comment.