bjchambers commented on a change in pull request #555:
URL: https://github.com/apache/arrow-rs/pull/555#discussion_r670941529
##########
File path: arrow/src/array/equal/mod.rs
##########
@@ -1019,6 +1019,136 @@ mod tests {
test_equal(&a, &b, true);
}
+ fn make_struct(
+ elements: Vec<Option<(Option<&'static str>, Option<i32>)>>,
+ ) -> StructArray {
+ let mut builder = StructBuilder::new(
+ vec![
+ Field::new("f1", DataType::Utf8, true),
+ Field::new("f2", DataType::Int32, true),
+ ],
+ vec![
+ Box::new(StringBuilder::new(elements.len())),
+ Box::new(Int32Builder::new(elements.len())),
+ ],
+ );
+
+ for element in elements {
+ match element.and_then(|e| e.0) {
+ None => builder
+ .field_builder::<StringBuilder>(0)
+ .unwrap()
+ .append_null()
+ .unwrap(),
+ Some(s) => builder
+ .field_builder::<StringBuilder>(0)
+ .unwrap()
+ .append_value(s)
+ .unwrap(),
+ };
+
+ builder
+ .field_builder::<Int32Builder>(1)
+ .unwrap()
+ .append_option(element.and_then(|e| e.1))
+ .unwrap();
+
+ builder.append(element.is_some()).unwrap();
+ }
+
+ builder.finish()
+ }
+
+ #[test]
+ fn test_struct_equal_slice() {
+ let a = make_struct(vec![
+ None,
+ Some((Some("joe"), Some(1))),
+ Some((None, Some(2))),
+ Some((None, None)),
+ Some((Some("mark"), Some(4))),
+ Some((Some("doe"), Some(5))),
+ ]);
+ let a = a.slice(1, 5);
+ let a = a.as_any().downcast_ref::<StructArray>().unwrap();
+
+ let b = make_struct(vec![
+ Some((Some("joe"), Some(1))),
+ Some((None, Some(2))),
+ Some((None, None)),
+ Some((Some("mark"), Some(4))),
+ Some((Some("doe"), Some(5))),
+ ]);
+ assert_eq!(a, &b);
Review comment:
This test is still falsely failing. I've made some changes (I think the
null-counts were respecting the buffer offset, but not the bit-offset from the
slice). Once that is fixed, I'm now hitting the same problems with the
`child_logical_null_buffer`, but I'm not sure how to fix that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]