Attach `Diagnostic` to "duplicate table name" error
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Is your feature request related to a problem or challenge?
For a query like:
```sql
SELECT * FROM users a, users a
```
The only message that the end user of an application built atop of DataFusion sees is:
```
Schema error: Schema contains duplicate qualified field name a.id
```
Similarly, for:
```sql
WITH cte AS (SELECT 1 AS col), cte AS (SELECT 2 AS col) SELECT 1
```
We get:
```
Error during planning: WITH query name "cte" specified more than once
```
We want to provide a richer message that _references and highlights locations in the original SQL query_, and contextualises and helps the user understand the error. In the end, it would be possible to display errors in a fashion akin to what was enabled by #13664 for some errors:

See #14429 for more information.
### Describe the solution you'd like
Attach a well crafted `Diagnostic` to the `DataFusionError`, building on top of the foundations laid in #13664. See #14429 for more information.
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.