Repository: jorgecarleitao/arrow2
Pull request #1244 (2022-09-08 07:12:16)

fixed `neq_and_validity` in the default case w/ nulls
Fixed a bug introduced in #1243 and added a test for that case.

codecov[bot]: # [Codecov](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1244?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) Report
> Merging [#1244](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1244?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) (2dcb35d) into [main](https://codecov.io/gh/jorgecarleitao/arrow2/commit/6c102a0c3e2dbeb185360dd3d5c3637b5e2028fd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) (6c102a0) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##             main    #1244   +/-   ##
=======================================
  Coverage   83.32%   83.32%           
=======================================
  Files         359      359           
  Lines       37939    37941    +2     
=======================================
+ Hits        31613    31616    +3     
+ Misses       6326     6325    -1     
```


| [Impacted Files](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1244?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) | Coverage Δ | |
|---|---|---|
| [src/compute/comparison/mod.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvY29tcGFyaXNvbi9tb2QucnM=) | `65.59% <100.00%> (+0.37%)` | :arrow_up: |
| [src/io/ipc/read/schema.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2lvL2lwYy9yZWFkL3NjaGVtYS5ycw==) | `95.49% <0.00%> (-0.31%)` | :arrow_down: |
| [src/io/ipc/read/file.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2lvL2lwYy9yZWFkL2ZpbGUucnM=) | `97.32% <0.00%> (+0.44%)` | :arrow_up: |
| [src/bitmap/immutable.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/1244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2JpdG1hcC9pbW11dGFibGUucnM=) | `86.41% <0.00%> (+0.61%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao)


Patch:
diff --git a/src/compute/comparison/mod.rs b/src/compute/comparison/mod.rs
index ba6a84e49b..9457e0adf0 100644
--- a/src/compute/comparison/mod.rs
+++ b/src/compute/comparison/mod.rs
@@ -612,9 +612,12 @@ fn finish_neq_validities(
                     if both_sides_invalid.values().unset_bits() != both_sides_invalid.len() {
                         // we use the `binary` kernel directly to save allocations
                         // and apply `lhs & !rhs)` in one shot.
-                        compute::boolean::binary_boolean_kernel(&lhs, &rhs, |lhs, rhs| {
-                            binary(lhs, rhs, |lhs, rhs| (lhs & !rhs))
-                        })
+
+                        compute::boolean::binary_boolean_kernel(
+                            &or,
+                            &both_sides_invalid,
+                            |lhs, rhs| binary(lhs, rhs, |lhs, rhs| (lhs & !rhs)),
+                        )
                     } else {
                         or
                     }


Test patch:
diff --git a/tests/it/compute/comparison.rs b/tests/it/compute/comparison.rs
index b077e99610..eb5058d337 100644
--- a/tests/it/compute/comparison.rs
+++ b/tests/it/compute/comparison.rs
@@ -383,7 +383,7 @@ fn primitive_gt_eq() {
 }
 
 #[test]
-#[cfg(any(feature = "compute_cast", feature = "compute_boolean_kleene"))]
+#[cfg(all(feature = "compute_cast", feature = "compute_boolean_kleene"))]
 fn utf8_and_validity() {
     use arrow2::compute::cast::CastOptions;
     let a1 = Utf8Array::<i32>::from([Some("0"), Some("1"), None, Some("2")]);
@@ -401,3 +401,16 @@ fn utf8_and_validity() {
     assert_eq!(utf8::neq_and_validity(&a1, &a1), expected);
     assert_eq!(utf8::neq_and_validity(&a1, a2), expected);
 }
+
+#[test]
+#[cfg(feature = "compute_boolean_kleene")]
+fn primitive_and_validity() {
+    let a1 = Int32Array::from([Some(0), None]);
+    let a2 = Int32Array::from([Some(10), None]);
+
+    let expected = BooleanArray::from_slice([true, false]);
+    assert_eq!(primitive::neq_and_validity(&a1, &a2), expected);
+
+    let expected = BooleanArray::from_slice([false, true]);
+    assert_eq!(primitive::eq_and_validity(&a1, &a2), expected);
+}