This is an automated email from the ASF dual-hosted git repository.
Jefffrey pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new f0dd1c23c7 chore: Refine the error message for List to non List cast
(#9757)
f0dd1c23c7 is described below
commit f0dd1c23c70ba9c5c1c312b5e1d85db59da0af2f
Author: Oleks V <[email protected]>
AuthorDate: Sun Apr 19 04:06:34 2026 -0700
chore: Refine the error message for List to non List cast (#9757)
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax.
-->
- Closes #NNN.
# Rationale for this change
Originally came from
https://github.com/apache/datafusion-comet/pull/3954
Getting the error message which hides the CAST target `data_type`
```
Cause: org.apache.comet.CometNativeException: External error: Arrow
error: Cast error: Cannot cast list to non-list data types
```
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
# Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
---
arrow-cast/src/cast/mod.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arrow-cast/src/cast/mod.rs b/arrow-cast/src/cast/mod.rs
index c96e7c8f6a..5f08dcbfc1 100644
--- a/arrow-cast/src/cast/mod.rs
+++ b/arrow-cast/src/cast/mod.rs
@@ -913,9 +913,9 @@ pub fn cast_with_options(
Utf8 => value_to_string::<i32>(array, cast_options),
LargeUtf8 => value_to_string::<i64>(array, cast_options),
Utf8View => value_to_string_view(array, cast_options),
- _ => Err(ArrowError::CastError(
- "Cannot cast list to non-list data types".to_string(),
- )),
+ dt => Err(ArrowError::CastError(format!(
+ "Cannot cast LIST to non-list data type {dt}"
+ ))),
},
(_, List(to)) => cast_values_to_list::<i32>(array, to, cast_options),
(_, LargeList(to)) => cast_values_to_list::<i64>(array, to,
cast_options),