You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/08/23 01:48:51 UTC
[GitHub] [arrow-rs] liukun4515 commented on a diff in pull request #2555: Add test for float nan equality comparison
liukun4515 commented on code in PR #2555:
URL: https://github.com/apache/arrow-rs/pull/2555#discussion_r952065112
##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -5278,4 +5278,74 @@ mod tests {
BooleanArray::from(vec![Some(true), None, Some(false)])
);
}
+
+ #[test]
+ fn test_eq_dyn_neq_dyn_float_nan() {
+ let array1: Float32Array = vec![f32::NAN, 7.0, 8.0, 8.0, 10.0]
+ .into_iter()
+ .map(Some)
+ .collect();
+ let array2: Float32Array = vec![f32::NAN, f32::NAN, 8.0, 8.0, 10.0]
+ .into_iter()
+ .map(Some)
+ .collect();
+ let expected = BooleanArray::from(
+ vec![Some(false), Some(false), Some(true), Some(true), Some(true)],
+ );
+ assert_eq!(eq_dyn(&array1, &array2).unwrap(), expected);
+
+ let expected = BooleanArray::from(
+ vec![Some(true), Some(true), Some(false), Some(false), Some(false)],
+ );
+ assert_eq!(neq_dyn(&array1, &array2).unwrap(), expected);
+
+ let array1: Float64Array = vec![f64::NAN, 7.0, 8.0, 8.0, 10.0]
+ .into_iter()
+ .map(Some)
+ .collect();
+ let array2: Float64Array = vec![f64::NAN, f64::NAN, 8.0, 8.0, 10.0]
+ .into_iter()
+ .map(Some)
+ .collect();
+ let expected = BooleanArray::from(
+ vec![Some(false), Some(false), Some(true), Some(true), Some(true)],
+ );
+ assert_eq!(eq_dyn(&array1, &array2).unwrap(), expected);
+
+ let expected = BooleanArray::from(
+ vec![Some(true), Some(true), Some(false), Some(false), Some(false)],
+ );
+ assert_eq!(neq_dyn(&array1, &array2).unwrap(), expected);
+ }
+
+ #[test]
+ fn test_eq_dyn_scalar_neq_dyn_scalar_float_nan() {
Review Comment:
Can you add other compare operations like `lt,lt_eq`?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org