Skip to content

Commit

Permalink
Further tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Sep 1, 2023
1 parent 93fb4da commit ee630e5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions arrow-select/src/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,4 +823,16 @@ mod tests {
assert_eq!(data.buffers()[1].len(), 200);
assert_eq!(data.buffers()[1].capacity(), 256); // Nearest multiple of 64
}

#[test]
fn concat_sparse_nulls() {
let values = StringArray::from_iter_values((0..100).map(|x| x.to_string()));
let keys = Int32Array::from(vec![1; 10]);
let dict_a = DictionaryArray::new(keys, Arc::new(values));
let values = StringArray::new_null(0);
let keys = Int32Array::new_null(10);
let dict_b = DictionaryArray::new(keys, Arc::new(values));
let array = concat(&[&dict_a, &dict_b]).unwrap();
assert_eq!(array.null_count(), 10);
}
}
21 changes: 21 additions & 0 deletions arrow-select/src/interleave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,25 @@ mod tests {

assert_eq!(v, &expected);
}

#[test]
fn interleave_sparse_nulls() {
let values = StringArray::from_iter_values((0..100).map(|x| x.to_string()));
let keys = Int32Array::from_iter_values(0..10);
let dict_a = DictionaryArray::new(keys, Arc::new(values));
let values = StringArray::new_null(0);
let keys = Int32Array::new_null(10);
let dict_b = DictionaryArray::new(keys, Arc::new(values));

let indices = &[(0, 0), (0, 1), (0, 2), (1, 0)];
let array = interleave(&[&dict_a, &dict_b], indices).unwrap();

let expected = DictionaryArray::<Int32Type>::from_iter(vec![
Some("0"),
Some("1"),
Some("2"),
None,
]);
assert_eq!(array.as_ref(), &expected)
}
}

0 comments on commit ee630e5

Please sign in to comment.