andygrove commented on code in PR #3347:
URL: https://github.com/apache/arrow-datafusion/pull/3347#discussion_r962054903
##########
datafusion/physical-expr/src/aggregate/approx_distinct.rs:
##########
@@ -219,7 +219,11 @@ macro_rules! default_accumulator_impl {
() => {
fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<()> {
assert_eq!(1, states.len(), "expect only 1 element in the states");
- let binary_array =
states[0].as_any().downcast_ref::<BinaryArray>().unwrap();
+ let binary_array =
states[0].as_any().downcast_ref::<BinaryArray>().ok_or(
Review Comment:
There is already a macro defined in this file that looks like what we need
```
macro_rules! downcast_value {
($Value: expr, $Type: ident, $T: tt) => {{
$Value[0]
.as_any()
.downcast_ref::<$Type<T>>()
.ok_or_else(|| {
DataFusionError::Internal(format!(
"could not cast value to {}",
type_name::<$Type<T>>()
))
})?
}};
}
```
--
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]