haohuaijin opened a new issue, #24919:
URL: https://github.com/apache/datafusion/issues/24919

   ### Is your feature request related to a problem or challenge?
   
   When a cast fails during query execution, the error reports the invalid 
value and target type but does not identify the source field. For queries with 
many casts, this makes it difficult to determine which input field contains the 
invalid value.
   
   For example, the current error is:
   
   ```text
   Arrow error: Cast error: Cannot cast string 'abc' to value of Int32 type
   ```
   
   The error does not indicate that the invalid value came from field `a`.
   
   ### Describe the solution you'd like
   
   Run the following statements in the DataFusion CLI:
   
   ```sql
   CREATE TABLE t(a TEXT) AS VALUES ('123'), ('abc');
   SELECT CAST(a AS INT) FROM t;
   ```
   
   The query fails with an error similar to:
   
   ```text
   Arrow error: Cast error: Cannot cast string 'abc' to value of Int32 type
   ```
   
   
   ### Describe alternatives you've considered
   
   The error should include the source field while retaining the original Arrow 
error as its cause. For example:
   
   ```text
   Failed to cast field 'a' from Utf8View to Int32
   caused by
   Arrow error: Cast error: Cannot cast string 'abc' to value of Int32 type
   ```
   
   The exact source string type may be `Utf8` or `Utf8View`, depending on the 
configuration.
   
   ### Additional context
   
   _No response_


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to