Dandandan commented on code in PR #8511:
URL: https://github.com/apache/arrow-datafusion/pull/8511#discussion_r1423738074
##########
datafusion/physical-expr/src/aggregate/count.rs:
##########
@@ -196,18 +202,22 @@ impl GroupsAccumulator for CountGroupsAccumulator {
/// for each row if one column value is null, then null_count + 1
fn null_count_for_multiple_cols(values: &[ArrayRef]) -> usize {
if values.len() > 1 {
- let result_bool_buf: Option<BooleanBuffer> = values
- .iter()
- .map(|a| a.nulls())
- .fold(None, |acc, b| match (acc, b) {
- (Some(acc), Some(b)) => Some(acc.bitand(b.inner())),
- (Some(acc), None) => Some(acc),
- (None, Some(b)) => Some(b.inner().clone()),
- _ => None,
+ let result_bool_buf: Option<BooleanBuffer> =
+ values.iter().fold(None, |acc, a| match (acc, a) {
+ (Some(acc), a) if a.data_type() == &DataType::Null => {
+ Some(acc.bitand(a.logical_nulls()?.inner()))
+ }
+ (Some(acc), a) => Some(acc.bitand(a.nulls()?.inner())),
+ (None, a) => Some(a.logical_nulls()?.into_inner()),
});
result_bool_buf.map_or(0, |b| values[0].len() - b.count_set_bits())
} else {
- values[0].null_count()
+ let values = &values[0];
+ if values.data_type() == &DataType::Null {
+ values.len()
+ } else {
+ values.null_count()
Review Comment:
Could be all based on `logical_nulls` as well
--
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]