HaoYang670 commented on code in PR #2600:
URL: https://github.com/apache/arrow-rs/pull/2600#discussion_r956703858


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2670,10 +2670,54 @@ pub fn eq_dyn(left: &dyn Array, right: &dyn Array) -> 
Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a == b, |a, b| a == b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a == b,
+                |a, b| a == b,
+                |a, b| a == b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a == b,
+                |a, b| a == b,
+                |a, b| {
+                    if is_nan(a) && is_nan(b) {
+                        true
+                    } else {
+                        a == b
+                    }
+                }
+            );
         }
         _ if matches!(right.data_type(), DataType::Dictionary(_, _)) => {
-            typed_cmp_dict_non_dict!(right, left, |a, b| a == b, |a, b| a == b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a == b,
+                |a, b| a == b,
+                |a, b| a == b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a == b,
+                |a, b| a == b,
+                |a, b| {
+                    if is_nan(a) && is_nan(b) {
+                        true
+                    } else {
+                        a == b
+                    }

Review Comment:
   minor
   ```suggestion
   (is_nan(a) && is_nan(b)) || a == b)
   ```



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2670,10 +2670,54 @@ pub fn eq_dyn(left: &dyn Array, right: &dyn Array) -> 
Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a == b, |a, b| a == b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a == b,
+                |a, b| a == b,
+                |a, b| a == b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a == b,
+                |a, b| a == b,
+                |a, b| {
+                    if is_nan(a) && is_nan(b) {
+                        true
+                    } else {
+                        a == b
+                    }

Review Comment:
   minor: 
   ```suggestion
   (is_nan(a) && is_nan(b)) || (a == b)
   ```



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2752,10 +2796,54 @@ pub fn neq_dyn(left: &dyn Array, right: &dyn Array) -> 
Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a != b, |a, b| a != b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a != b,
+                |a, b| a != b,
+                |a, b| a != b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a != b,
+                |a, b| a != b,
+                |a, b| {
+                    if is_nan(a) && is_nan(b) {
+                        false
+                    } else {
+                        a != b
+                    }

Review Comment:
   minor
   ```suggestion
   !(is_nan(a) && is_nan(b)) && (a != b)
   ```



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -3084,10 +3312,54 @@ pub fn gt_eq_dyn(left: &dyn Array, right: &dyn Array) 
-> Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a >= b, |a, b| a >= b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a >= b,
+                |a, b| a >= b,
+                |a, b| a >= b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a >= b,
+                |a, b| a >= b,
+                |a, b| {
+                    if is_nan(a) {
+                        true
+                    } else {
+                        a >= b
+                    }
+                }
+            );
         }
         _ if matches!(right.data_type(), DataType::Dictionary(_, _)) => {
-            typed_cmp_dict_non_dict!(right, left, |a, b| a <= b, |a, b| a <= b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a <= b,
+                |a, b| a <= b,
+                |a, b| a <= b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a <= b,
+                |a, b| a <= b,
+                |a, b| {
+                    if is_nan(b) {
+                        true
+                    } else {
+                        a <= b
+                    }

Review Comment:
   minor: 
   ```suggestion
   is_nan(b) || (a <= b)
   ```



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2919,10 +3055,54 @@ pub fn lt_eq_dyn(left: &dyn Array, right: &dyn Array) 
-> Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a <= b, |a, b| a <= b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a <= b,
+                |a, b| a <= b,
+                |a, b| a <= b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a <= b,
+                |a, b| a <= b,
+                |a, b| {
+                    if is_nan(a) {
+                        is_nan(b)
+                    } else {
+                        a <= b
+                    }
+                }
+            );
         }
         _ if matches!(right.data_type(), DataType::Dictionary(_, _)) => {
-            typed_cmp_dict_non_dict!(right, left, |a, b| a >= b, |a, b| a >= b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a >= b,
+                |a, b| a >= b,
+                |a, b| a >= b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a >= b,
+                |a, b| a >= b,
+                |a, b| {
+                    if is_nan(b) {
+                        is_nan(a)
+                    } else {
+                        a >= b
+                    }

Review Comment:
   minor
   ```suggestion
   (is_nan(b) && is_nan(a)) || (!is_nan(b) && (a >= b))
   ```



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2836,10 +2924,58 @@ pub fn lt_dyn(left: &dyn Array, right: &dyn Array) -> 
Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a < b, |a, b| a < b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a < b,
+                |a, b| a < b,
+                |a, b| a < b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a < b,
+                |a, b| a < b,
+                |a, b| {
+                    if is_nan(a) {
+                        false
+                    } else if is_nan(b) {
+                        true
+                    } else {
+                        a < b
+                    }

Review Comment:
   minor
   ```suggestion
   !is_nan(a) && (is_nan(b) || (a < b))
   ```



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2752,10 +2796,54 @@ pub fn neq_dyn(left: &dyn Array, right: &dyn Array) -> 
Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a != b, |a, b| a != b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a != b,
+                |a, b| a != b,
+                |a, b| a != b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a != b,
+                |a, b| a != b,
+                |a, b| {
+                    if is_nan(a) && is_nan(b) {
+                        false
+                    } else {
+                        a != b
+                    }
+                }
+            );
         }
         _ if matches!(right.data_type(), DataType::Dictionary(_, _)) => {
-            typed_cmp_dict_non_dict!(right, left, |a, b| a != b, |a, b| a != b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a != b,
+                |a, b| a != b,
+                |a, b| a != b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a != b,
+                |a, b| a != b,
+                |a, b| {
+                    if is_nan(a) && is_nan(b) {
+                        false
+                    } else {
+                        a != b
+                    }

Review Comment:
   minor
   ```suggestion
   !(is_nan(a) && is_nan(b)) && (a != b)
   ```



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -3084,10 +3312,54 @@ pub fn gt_eq_dyn(left: &dyn Array, right: &dyn Array) 
-> Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a >= b, |a, b| a >= b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a >= b,
+                |a, b| a >= b,
+                |a, b| a >= b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a >= b,
+                |a, b| a >= b,
+                |a, b| {
+                    if is_nan(a) {
+                        true
+                    } else {
+                        a >= b
+                    }

Review Comment:
   minor:
   ```suggestion
   is_nan(a) || (a >= b)
   ```



##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -3002,10 +3182,58 @@ pub fn gt_dyn(left: &dyn Array, right: &dyn Array) -> 
Result<BooleanArray> {
         DataType::Dictionary(_, _)
             if !matches!(right.data_type(), DataType::Dictionary(_, _)) =>
         {
-            typed_cmp_dict_non_dict!(left, right, |a, b| a > b, |a, b| a > b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a > b,
+                |a, b| a > b,
+                |a, b| a > b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                left,
+                right,
+                |a, b| a > b,
+                |a, b| a > b,
+                |a, b| {
+                    if is_nan(a) {
+                        !is_nan(b)
+                    } else if is_nan(b) {
+                        false
+                    } else {
+                        a > b
+                    }
+                }
+            );
         }
         _ if matches!(right.data_type(), DataType::Dictionary(_, _)) => {
-            typed_cmp_dict_non_dict!(right, left, |a, b| a < b, |a, b| a < b)
+            #[cfg(not(feature = "nan_ordering"))]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a < b,
+                |a, b| a < b,
+                |a, b| a < b
+            );
+
+            #[cfg(feature = "nan_ordering")]
+            return typed_cmp_dict_non_dict!(
+                right,
+                left,
+                |a, b| a < b,
+                |a, b| a < b,
+                |a, b| {
+                    if is_nan(b) {
+                        !is_nan(a)
+                    } else if is_nan(a) {
+                        false
+                    } else {
+                        a < b
+                    }

Review Comment:
   minor
   ```suggestion
   (is_nan(b) && !is_nan(a) ) ||
   (!is_nan(b) && !is_nan(a) && (a < b))
   ```



-- 
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]

Reply via email to