8000 Improve error reporting for missing qualified columns by Mytherin · Pull Request #17397 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve error reporting for missing qualified columns #17397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025

Conversation

Mytherin
Copy link
Collaborator
@Mytherin Mytherin commented May 7, 2025

When binding qualified columns (e.g. catalog.schema.table.column) we have several different methods of binding, e.g.:

catalog.schema.table.column.[fields]
catalog.table.column.[fields]
schema.table.column.[fields]
table.column.[fields]
column.[fields]

When binding, we are clever about figuring out which configuration is used to find the "right" one, allowing users to flexibly qualify columns.

When columns are not present, however, this gets more difficult. Currently, we always fall back to assuming the first field is the table (i.e. the qualification is [table].[column].[fields]). In this PR, we expand this so that we improve the error message by figuring out which qualifications are possible. For example, if there is a typo in a table name, but [catalog].[schema] exists in the query - we report an error as if we are binding catalog.schema.table.column. This provides better error messages, e.g.:

attach ':memory:' as cat;
create schema cat.schema;
create table cat.schema.tbl(col struct(field int));


select cxt.schema.tbl.col.field from cat.schema.tbl;
-- Referenced table "cxt.schema.tbl" not found!
-- Candidate tables: "cat.schema.tbl"

select cat.schxma.tbl.col.field from cat.schema.tbl;
-- Referenced table "cat.schxma.tbl" not found!
-- Candidate tables: "cat.schema.tbl"

select cat.schema.txl.col.field from cat.schema.tbl;
-- Referenced table "cat.schema.txl" not found!
-- Candidate tables: "cat.schema.tbl"

select cat.schema.tbl.cxl.field from cat.schema.tbl;
-- Table "tbl" does not have a column named "cxl"
-- Candidate bindings: : "col"

select cat.schema.tbl.col.feild from cat.schema.tbl;
-- Could not find key "feild" in struct
-- Candidate Entries: "field"

@Mytherin Mytherin merged commit ff3a129 into duckdb:main May 8, 2025
46 of 47 checks passed
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 18, 2025
Improve error reporting for missing qualified columns (duckdb/duckdb#17397)
Fix Python CI: pin virtualenv to previous version (duckdb/duckdb#17386)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 18, 2025
Improve error reporting for missing qualified columns (duckdb/duckdb#17397)
Fix Python CI: pin virtualenv to previous version (duckdb/duckdb#17386)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 19, 2025
Improve error reporting for missing qualified columns (duckdb/duckdb#17397)
Fix Python CI: pin virtualenv to previous version (duckdb/duckdb#17386)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 19, 2025
Improve error reporting for missing qualified columns (duckdb/duckdb#17397)
Fix Python CI: pin virtualenv to previous version (duckdb/duckdb#17386)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0