Skip to content

Commit f0dd1c2

Browse files
authored
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 apache/datafusion-comet#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. -->
1 parent 51b02f1 commit f0dd1c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arrow-cast/src/cast/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,9 @@ pub fn cast_with_options(
913913
Utf8 => value_to_string::<i32>(array, cast_options),
914914
LargeUtf8 => value_to_string::<i64>(array, cast_options),
915915
Utf8View => value_to_string_view(array, cast_options),
916-
_ => Err(ArrowError::CastError(
917-
"Cannot cast list to non-list data types".to_string(),
918-
)),
916+
dt => Err(ArrowError::CastError(format!(
917+
"Cannot cast LIST to non-list data type {dt}"
918+
))),
919919
},
920920
(_, List(to)) => cast_values_to_list::<i32>(array, to, cast_options),
921921
(_, LargeList(to)) => cast_values_to_list::<i64>(array, to, cast_options),

0 commit comments

Comments
 (0)