jayzhan211 commented on code in PR #9679:
URL: https://github.com/apache/arrow-datafusion/pull/9679#discussion_r1531317523
##########
datafusion/physical-expr/src/aggregate/count_distinct/mod.rs:
##########
@@ -246,15 +255,24 @@ impl Accumulator for DistinctCountAccumulator {
})
}
+ /// Merges multiple sets of distinct values into the current set.
+ ///
+ /// The input to this function is a `ListArray` with **multiple** rows,
+ /// where each row contains the values from a partial aggregate's phase
(e.g.
+ /// the result of calling `Self::state` on multiple accumulators).
fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<()> {
if states.is_empty() {
return Ok(());
}
assert_eq!(states.len(), 1, "array_agg states must be singleton!");
let array = &states[0];
let list_array = array.as_list::<i32>();
- let inner_array = list_array.value(0);
- self.update_batch(&[inner_array])
+ for inner_array in list_array.iter() {
+ let inner_array = inner_array
+ .expect("counts are always non null, so are intermediate
results");
Review Comment:
It panics, but it is fine if it is ensured to be non-null. I am looking into
how the array was built in the above comment but failed. 😢
--
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]