From ee630e5f3503bd59fcf8cca17209d0327c75a6ac Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies Date: Fri, 1 Sep 2023 13:29:07 +0100 Subject: [PATCH] Further tests --- arrow-select/src/concat.rs | 12 ++++++++++++ arrow-select/src/interleave.rs | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/arrow-select/src/concat.rs b/arrow-select/src/concat.rs index 0a298532fdf6..8bf620bd64c9 100644 --- a/arrow-select/src/concat.rs +++ b/arrow-select/src/concat.rs @@ -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); + } } diff --git a/arrow-select/src/interleave.rs b/arrow-select/src/interleave.rs index 879ef96ae58b..914173020ce0 100644 --- a/arrow-select/src/interleave.rs +++ b/arrow-select/src/interleave.rs @@ -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::::from_iter(vec![ + Some("0"), + Some("1"), + Some("2"), + None, + ]); + assert_eq!(array.as_ref(), &expected) + } }