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

Ensure arrays passed to MutableArrayData have same type (#5091) #5092

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions arrow-data/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ impl<'a> MutableArrayData<'a> {
) -> Self {
let data_type = arrays[0].data_type();

for a in arrays.iter().skip(1) {
assert_eq!(
data_type,
a.data_type(),
"Arrays with inconsistent types passed to MutableArrayData"
)
}

// if any of the arrays has nulls, insertions from any array requires setting bits
// as there is at least one array with nulls.
let use_nulls = use_nulls | arrays.iter().any(|array| array.null_count() > 0);
Expand Down
8 changes: 8 additions & 0 deletions arrow/tests/array_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,14 @@ fn test_extend_nulls_panic() {
mutable.extend_nulls(2);
}

#[test]
#[should_panic(expected = "Arrays with inconsistent types passed to MutableArrayData")]
fn test_mixed_types() {
let a = StringArray::from(vec!["abc", "def"]).to_data();
let b = Int32Array::from(vec![1, 2, 3]).to_data();
MutableArrayData::new(vec![&a, &b], false, 4);
}

/*
// this is an old test used on a meanwhile removed dead code
// that is still useful when `MutableArrayData` supports fixed-size lists.
Expand Down
Loading