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/29 17:07:23 UTC
[GitHub] [arrow-rs] sunchao commented on a diff in pull request #2600: Support SQL-compliant NaN ordering for DictionaryArray and non-DictionaryArray
sunchao commented on code in PR #2600:
URL: https://github.com/apache/arrow-rs/pull/2600#discussion_r957586232
##########
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:
Agree. It's more readable this way.
--
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