-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
Description
What happens?
Consider the case where there are multiple schemas with the same matching score for a Catalog error.
create schema a;
create schema b;
create table a.foo(name text);
create table b.foo(name text);
select * from foo;
Catalog Error: Table with name foo does not exist!
Did you mean "b.foo"?
LINE 1: select * from foo;
There is an equally qualified match in schema a
, but Catalog Error just presents the last match.
Here is the relevant snippet of code.
duckdb/src/catalog/catalog.cpp
Lines 639 to 654 in 45787e5
static constexpr const double UNSEEN_PENALTY = 0.2; | |
auto unseen_entry = SimilarEntryInSchemas(context, entry_name, type, unseen_schemas); | |
string did_you_mean; | |
if (unseen_entry.Found() && (unseen_entry.score == 1.0 || unseen_entry.score - UNSEEN_PENALTY > entry.score)) { | |
// the closest matching entry requires qualification as it is not in the default search path | |
// check how to minimally qualify this entry | |
auto catalog_name = unseen_entry.schema->catalog.GetName(); | |
auto schema_name = unseen_entry.schema->name; | |
bool qualify_database; | |
bool qualify_schema; | |
FindMinimalQualification(context, catalog_name, schema_name, qualify_database, qualify_schema); | |
did_you_mean = unseen_entry.GetQualifiedName(qualify_database, qualify_schema); | |
} else if (entry.Found()) { | |
did_you_mean = entry.name; | |
} | |
return CatalogException::MissingEntry(type, entry_name, did_you_mean, error_context); |
I'd suggest that the code should be changed to present all suggestions that have the same score so that the a user that has tables in multiple schemas with the same name can make the appropriate choice.
Thanks,
Rusty
To Reproduce
create schema a;
create schema b;
create table a.foo(name text);
create table b.foo(name text);
select * from foo;
OS:
Mac OS X
DuckDB Version:
1.0.0
DuckDB Client:
CLI
Full Name:
Rusty Conover
Affiliation:
self
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- Yes, I have