You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Attach Diagnostic to "duplicate table name" error #14436
Is your feature request related to a problem or challenge?
For a query like:
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:
WITH cte AS (SELECT1AS col), cte AS (SELECT2AS col) SELECT1
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:
DFParser::parse_sql(query) returns an Ok for both examples in the OP 🤔 Did something change in the meantime to allow these ambiguous references or am I missing something?
My test is
#[test]fntest_ambiguous_with_diagnostic() -> Result<()>{// let query = "SELECT * FROM users a, users a";let query = "WITH cte AS (SELECT 1 AS col), cte AS (SELECT 2 AS col) SELECT 1";let spans = get_spans(query);matchDFParser::parse_sql(query){Ok(stmts) => {panic!("expected error, got {:?}", stmts);}Err(err) => match err.diagnostic(){Some(diag) => {let diag = diag.clone();assert_snapshot!(diag.message, @"TODO");Ok(())}None => {panic!("expected diagnostic")}},}}
Activity
alamb commentedon Feb 4, 2025
I think this is a good first issue as the need is clear and the tests in https://github.com/apache/datafusion/blob/85fbde2661bdb462fc498dc18f055c44f229604c/datafusion/sql/tests/cases/diagnostic.rs are well structured for extension.
zjregee commentedon Feb 5, 2025
take
eliaperantoni commentedon Feb 13, 2025
Hey @zjregee how is it going with this ticket :) Can I help with anything?
zjregee commentedon Feb 17, 2025
Sorry for the delay, I will start and finish it in the next few days.
vegarsti commentedon Jul 28, 2025
Take
vegarsti commentedon Jul 29, 2025
DFParser::parse_sql(query)returns anOkfor both examples in the OP 🤔 Did something change in the meantime to allow these ambiguous references or am I missing something?My test is
amitvijapur commentedon Apr 6, 2026
Hi, I'd like to work on this. First-time contributor — will follow the pattern from PR #15209.
feat: attach Diagnostic to duplicate CTE name error
haochunchang commentedon Oct 8, 2026
The latest related PR is #20720 which had review feedback that was not yet addressed.
I can pick it up and try addressing reviewer's feedback.
haochunchang commentedon Oct 8, 2026
take
feat: attach Diagnostic to duplicate table name errors
feat: attach Diagnostic to duplicate table name errors