alamb commented on code in PR #11627:
URL: https://github.com/apache/datafusion/pull/11627#discussion_r1697609249
##########
datafusion/functions-aggregate/src/count.rs:
##########
@@ -433,6 +433,49 @@ impl GroupsAccumulator for CountGroupsAccumulator {
Ok(vec![Arc::new(counts) as ArrayRef])
}
+ fn convert_to_state(
+ &self,
+ values: &[ArrayRef],
+ opt_filter: Option<&BooleanArray>,
+ ) -> Result<Vec<ArrayRef>> {
+ let values = &values[0];
+
+ let state_array = match (values.logical_nulls(), opt_filter) {
+ (Some(nulls), None) => {
+ let mut builder = Int64Builder::with_capacity(values.len());
+ nulls
+ .into_iter()
+ .for_each(|is_valid| builder.append_value(is_valid as
i64));
+ builder.finish()
+ }
+ (Some(nulls), Some(filter)) => {
+ let mut builder = Int64Builder::with_capacity(values.len());
+ nulls.into_iter().zip(filter.iter()).for_each(
+ |(is_valid, filter_value)| {
+ builder.append_value(
Review Comment:
Maybe we can use the
[`nullif`](https://docs.rs/arrow/latest/arrow/compute/kernels/nullif/index.html)
kernel here
Something like
```rust
let nulls = and(nulls, not(filter));
let output = nullif(values);
```
Update: or maybe we could just `and` the nulls from the input and the filter
(as `nulls` is the validity mask` 🤔
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]