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

   ### Is your feature request related to a problem or challenge?
   
   `DataFusionError` does not provide information about the location inside the 
SQL query that caused it. It's difficult for the end user to understand where, 
in a large query, to go look for the cause of the error.
   
   ### Example:
   
   ```sql
   WITH products_with_price AS (
        SELECT
                id,
                name,
                price_usd
        FROM
                products
        JOIN
                prices
        ON
                products.id = prices.product_id
   )
   SELECT
        id,
        name,
        price_usd + '$' AS display_price_usd
   FROM
        products_with_price
   ```
   
   When creating a logical plan for this query, we'd return:
   
   ```
   Cannot coerce arithmetic expression Int64 + Utf8 to valid types
   ```
   
   It's up to the user to figure out that the error lies on the third-to-last 
line.
   
   ### Describe the solution you'd like
   
   With the AST nodes from the parser now containing the source code location 
(thanks to apache/datafusion-sqlparser-rs#1435), it now becomes possible to add 
the same information to errors. This could seriously improve the experience for 
end users, since they would be able to clearly see where in the queries the 
errors lie.
   
   In the example above, the desired feature of this ticket would be to add a 
reference to the third-to-last line, which is the cause of the error: 
`price_usd + '$' AS display_price_usd`.
   
   Furthermore, it would be helpful to link to additonal segments of code note 
that, despite not representing the root cause of the error, help the user 
understand the context around the error and the elements involved. In this 
example, we'd highlight the projected `price_usd` column in the CTE to help the 
user understand where it comes from.
   
   ### Describe alternatives you've considered
   
   `DataFusionError::Context` only adds additional debug strings, but doesn't 
attach source code location info.
   
   ### 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