tustvold commented on code in PR #2940:
URL: https://github.com/apache/arrow-rs/pull/2940#discussion_r1006165467
##########
arrow/src/compute/kernels/boolean.rs:
##########
@@ -1136,6 +1135,278 @@ mod tests {
Some(8), // None => keep it
None, // true => None
]);
- assert_eq!(&expected, &res)
+ let res = as_primitive_array::<Int32Type>(&res);
+ assert_eq!(&expected, res)
+ }
+
+ #[test]
+ fn test_nullif_string() {
+ let s = StringArray::from_iter([
+ Some("hello"),
+ None,
+ Some("world"),
+ Some("a"),
+ Some("b"),
+ None,
+ None,
+ ]);
+ let select = BooleanArray::from_iter([
+ Some(true),
+ Some(true),
+ Some(false),
+ Some(true),
+ Some(false),
+ Some(false),
+ None,
+ ]);
+
+ let a = nullif(&s, &select).unwrap();
+ let r: Vec<_> = as_string_array(&a).iter().collect();
+ assert_eq!(
+ r,
+ vec![None, None, Some("world"), None, Some("b"), None, None]
+ );
+
+ let s = s.slice(2, 3);
+ let select = select.slice(1, 3);
+ let select = as_boolean_array(select.as_ref());
+ let a = nullif(s.as_ref(), select).unwrap();
+ let r: Vec<_> = as_string_array(&a).iter().collect();
+ assert_eq!(r, vec![None, Some("a"), None]);
+ }
+
+ #[test]
Review Comment:
These tests are borrowed from @bjchambers original PR #521
--
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]