You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tobixdev (via GitHub)" <gi...@apache.org> on 2025/09/29 20:37:43 UTC
[I] Unintuitive Behavior of Collecting to a BooleanArray [arrow-rs]
tobixdev opened a new issue, #8505:
URL: https://github.com/apache/arrow-rs/issues/8505
**Describe the bug**
Collecting to a `BooleanArray` produces unintuitive results if the upper bound of the iterator is an over estimation. At least I think after looking at the code.
Is this intended behavior? If not, I could try to come up with a fix.
**To Reproduce**
The following test reproduces this:
```rust
#[test]
fn test_boolean_array_from() {
let values = vec![Some(true), None, Some(true), Some(false)]
.into_iter()
.filter(Option::is_some)
.collect::<BooleanArray>();
assert_debug_snapshot!(values, @r"
BooleanArray
[
true,
true,
false,
null,
]
")
}
```
**Expected behavior**
I'd have expected the following Array (without the null):
```
BooleanArray
[
true,
true,
false,
]
```
**Additional context**
The result of the "same" operation on an Int64Array:
```rust
#[test]
fn test_int64_array_from() {
let values = vec![Some(1), None, Some(2), Some(3)]
.into_iter()
.filter(Option::is_some)
.collect::<Int64Array>();
assert_debug_snapshot!(values, @r"
PrimitiveArray<Int64>
[
1,
2,
3,
]
")
}
```
--
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] Unintuitive Behavior of Collecting to a BooleanArray [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #8505:
URL: https://github.com/apache/arrow-rs/issues/8505#issuecomment-3360283316
> The former would use a (probably slower) builder for creating the boolean array, while the latter would do a similar thing to the current implementation.
Makes sense to me -- thank you @jhorstmann and @tobixdev
--
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] Incorrect Behavior of Collecting a filtered iterator to a BooleanArray [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #8505:
URL: https://github.com/apache/arrow-rs/issues/8505#issuecomment-3416679655
`label_issue.py` automatically added labels {'arrow'} from #8525
--
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] Unintuitive Behavior of Collecting to a BooleanArray [arrow-rs]
Posted by "jhorstmann (via GitHub)" <gi...@apache.org>.
jhorstmann commented on issue #8505:
URL: https://github.com/apache/arrow-rs/issues/8505#issuecomment-3355839582
Agree, this looks like a bug. The `FromIterator` impl uses the upper bound of the input as the resulting length: https://github.com/apache/arrow-rs/blob/b9c2bf73e792e7cb849f0bd453059ceef45b0b74/arrow-array/src/array/boolean_array.rs#L443
--
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] Unintuitive Behavior of Collecting to a BooleanArray [arrow-rs]
Posted by "tobixdev (via GitHub)" <gi...@apache.org>.
tobixdev commented on issue #8505:
URL: https://github.com/apache/arrow-rs/issues/8505#issuecomment-3355981122
I think a sustainable fix would be to separate the implementation into `from_iter` and `from_trusted_len_iter` similar to `PrimtiveArray`.
The former would use a (probably slower) builder for creating the boolean array, while the latter would do a similar thing to the current implementation.
--
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] Incorrect Behavior of Collecting a filtered iterator to a BooleanArray [arrow-rs]
Posted by "mbrobbel (via GitHub)" <gi...@apache.org>.
mbrobbel closed issue #8505: Incorrect Behavior of Collecting a filtered iterator to a BooleanArray
URL: https://github.com/apache/arrow-rs/issues/8505
--
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