Skip to content

Commit

Permalink
Minor: return internal error rather than panic on unexpected error in…
Browse files Browse the repository at this point in the history
… COUNT DISTINCT (apache#9712)

* Minor: return internal error rather than panic on unexpected error in COUNT DISTICT

* Update datafusion/physical-expr/src/aggregate/count_distinct/mod.rs

* Update datafusion/physical-expr/src/aggregate/count_distinct/mod.rs

Co-authored-by: comphead <[email protected]>

---------

Co-authored-by: comphead <[email protected]>
  • Loading branch information
alamb and comphead authored Mar 21, 2024
1 parent eda2ddf commit 6d74025
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions datafusion/physical-expr/src/aggregate/count_distinct/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use arrow_array::types::{
TimestampSecondType, UInt16Type, UInt32Type, UInt64Type, UInt8Type,
};

use datafusion_common::{Result, ScalarValue};
use datafusion_common::{internal_err, Result, ScalarValue};
use datafusion_expr::Accumulator;

use crate::aggregate::count_distinct::bytes::BytesDistinctCountAccumulator;
Expand Down Expand Up @@ -268,8 +268,11 @@ impl Accumulator for DistinctCountAccumulator {
let array = &states[0];
let list_array = array.as_list::<i32>();
for inner_array in list_array.iter() {
let inner_array = inner_array
.expect("counts are always non null, so are intermediate results");
let Some(inner_array) = inner_array else {
return internal_err!(
"Intermediate results of COUNT DISTINCT should always be non null"
);
};
self.update_batch(&[inner_array])?;
}
Ok(())
Expand Down

0 comments on commit 6d74025

Please sign in to comment.