junjunjd commented on code in PR #7901:
URL: https://github.com/apache/arrow-datafusion/pull/7901#discussion_r1379681340
##########
datafusion/common/src/scalar.rs:
##########
@@ -579,24 +581,44 @@ fn dict_from_values<K: ArrowDictionaryKeyType>(
macro_rules! typed_cast_tz {
($array:expr, $index:expr, $ARRAYTYPE:ident, $SCALAR:ident, $TZ:expr) => {{
- let array = $array.as_any().downcast_ref::<$ARRAYTYPE>().unwrap();
Review Comment:
`typed_cast_tz` macro is called by
[`try_from_array`](https://github.com/apache/arrow-datafusion/blob/main/datafusion/common/src/scalar.rs#L2021-L2022).
`try_from_array` is a public function. Depending on what array value the user
passes to the function, downcasting the array to a timestamp array can fail.
This error is reachable and recoverable. I think it makes sense to return an
internal error here. This aligns with how downcast error is handled in the
[downcast_value](https://github.com/apache/arrow-datafusion/blob/main/datafusion/common/src/lib.rs#L73)
macro.
This does not require any change in client code, since `typed_cast_tz` is
only used in `try_from_array`, which is already a `Result`.
--
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]