Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for creating FixedSizeBinaryArray::try_from_sparse_iter failed when given all Nones #1551

Merged
merged 3 commits into from
Apr 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1742,4 +1745,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();
}
}