alamb commented on code in PR #4061:
URL: https://github.com/apache/arrow-datafusion/pull/4061#discussion_r1012028046
##########
datafusion/common/src/cast.rs:
##########
@@ -32,3 +32,13 @@ pub fn as_date32_array(array: &dyn Array) ->
Result<&Date32Array, DataFusionErro
))
})
}
+
+// Downcast ArrayRef to Date32Array
Review Comment:
```suggestion
// Downcast ArrayRef to StructArray
```
##########
benchmarks/src/tpch.rs:
##########
@@ -439,7 +439,10 @@ fn col_to_scalar(column: &ArrayRef, row_index: usize) ->
ScalarValue {
ScalarValue::Decimal128(Some(array.value(row_index)), *p, *s)
}
DataType::Date32 => {
- let array = column.as_any().downcast_ref::<Date32Array>().unwrap();
+ let array = match as_date32_array(column) {
+ Ok(array) => array,
+ Err(e) => panic!("{}", e),
+ };
Review Comment:
I think `unwrap` will also print the error message if called on an error:
https://doc.rust-lang.org/std/result/enum.Result.html#panics-1
> Panics if the value is an
[Err](https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err), with
a panic message provided by the
[Err](https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err)’s
value.
```suggestion
let array = as_date32_array(column).unwrap();
```
##########
datafusion/common/src/scalar.rs:
##########
@@ -3611,7 +3604,10 @@ mod tests {
// iter_to_array for struct scalars
let array =
ScalarValue::iter_to_array(vec![s0.clone(), s1.clone(),
s2.clone()]).unwrap();
- let array = array.as_any().downcast_ref::<StructArray>().unwrap();
+ let array = match as_struct_array(&array) {
Review Comment:
see comment above
--
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]