apache / arrow-rs

Official Rust implementation of Apache Arrow
https://arrow.apache.org/
Apache License 2.0
2.62k stars 802 forks source link

Improve error message for unsupported cast between struct and other types #6724

Open andygrove opened 1 week ago

andygrove commented 1 week ago

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

In general, we have detailed error messages for unsupported casts, such as:

_ => Err(ArrowError::CastError(format!(
    "Casting from {from_type:?} to {to_type:?} not supported"

However, the messages for casting between struct and non-struct types does not provide information on the types that were attempted to be cast, making it harder to debug issues.

(Struct(_), _) => Err(ArrowError::CastError(
    "Cannot cast from struct to other types except struct".to_string(),
)),
(_, Struct(_)) => Err(ArrowError::CastError(
    "Cannot cast to struct from other types except struct".to_string(),
)),

Describe the solution you'd like

I would like the error message to follow the same format as other unsupported casts:

"Casting from {from_type:?} to {to_type:?} not supported"

Describe alternatives you've considered

Additional context

Silverviles commented 1 week ago

take