You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "yongster (via GitHub)" <gi...@apache.org> on 2026/08/15 11:07:50 UTC
[I] and_not produces incorrect results on sliced BooleanArrays [arrow-rs]
yongster opened a new issue, #10697:
URL: https://github.com/apache/arrow-rs/issues/10697
### Describe the bug
`and_not` is documented as equivalent to `and(left, not(right))`. That holds for unsliced `BooleanArray`s, but fails once either side is a `slice`.
The current implementation passes the left/right bit offsets in the wrong order to `buffer_bin_and_not`, then wraps the already-normalized (offset 0) result with `left.offset()` again:
```rust
let buffer = buffer_bin_and_not(a.inner(), b.offset(), b.inner(), a.offset(), a.len());
BooleanBuffer::new(buffer, left.offset(), left.len())
```
`and` does not have this bug because it uses `BooleanBuffer`'s `BitAnd` impl, which applies each buffer's own offset. Existing `and_not` tests only use offset 0, so they do not catch it. Added in #5297.
### To Reproduce
```rust
use arrow_array::BooleanArray;
use arrow_arith::boolean::{and, and_not, not};
#[test]
fn and_not_sliced_matches_and_not() {
let a = BooleanArray::from(vec![true, false, true, false, true, false, true]);
let b = BooleanArray::from(vec![false, true, false, true, false, true, false]);
// Unsliceed: docstring holds.
assert_eq!(and_not(&a, &b).unwrap(), and(&a, ¬(&b).unwrap()).unwrap());
let a = a.slice(2, 3);
let b = b.slice(2, 3);
// a = [true, false, true], b = [false, true, false]
// expected and_not = [true, false, true]
let got = and_not(&a, &b).unwrap();
let expected = and(&a, ¬(&b).unwrap()).unwrap();
assert_eq!(got, expected);
}
```
On current `main` this fails:
```
slice and_not = [true, false, false]
slice and+not = [true, false, true]
```
The same mismatch happens when the two slices start at different offsets.
### Expected behavior
`and_not(a, b)` should equal `and(a, not(b))` for sliced arrays as well as unsliced ones.
### Additional context
Found while comparing boolean kernels against their documented identities on sliced arrays. I ran the reproduction locally and reviewed the result.
This report was prepared with AI assistance.
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] and_not produces incorrect results on sliced BooleanArrays [arrow-rs]
Posted by "yongster (via GitHub)" <gi...@apache.org>.
yongster closed issue #10697: and_not produces incorrect results on sliced BooleanArrays
URL: https://github.com/apache/arrow-rs/issues/10697
--
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
Re: [I] and_not produces incorrect results on sliced BooleanArrays [arrow-rs]
Posted by "yongster (via GitHub)" <gi...@apache.org>.
yongster commented on issue #10697:
URL: https://github.com/apache/arrow-rs/issues/10697#issuecomment-5301954949
Closing this — filed prematurely before discussing which bug to take. Sorry for the noise.
--
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