Skip to content

Commit

Permalink
fix: improve error hints when select * from xx.yy (databendlabs#14663)
Browse files Browse the repository at this point in the history
* fix: improve error hints when select * from xx.yy

* fix: improve error hints when select * from xx.yy

* feat: add test

* feat: add test

* Update tests/sqllogictests/suites/base/issues/issue_13718.test

Co-authored-by: Bohu <[email protected]>

* fix issue_13718.test

---------

Co-authored-by: Bohu <[email protected]>
  • Loading branch information
zhenglin-charlie-li and BohuTANG authored Mar 24, 2024
1 parent c3b148d commit 3a50f2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/query/sql/src/planner/binder/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ impl Binder {
}
parent = bind_context.parent.as_mut();
}
if e.code() == ErrorCode::UNKNOWN_DATABASE {
return Err(ErrorCode::UnknownDatabase(format!(
"Unknown database `{}` in catalog '{catalog}'",
database
))
.set_span(*span));
}
if e.code() == ErrorCode::UNKNOWN_TABLE {
return Err(ErrorCode::UnknownTable(format!(
"Unknown table `{database}`.`{table_name}` in catalog '{catalog}'"
Expand Down
5 changes: 5 additions & 0 deletions tests/sqllogictests/suites/base/issues/issue_13718.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
statement ok
DROP DATABASE IF EXISTS xx

statement error (?s)1003.*Unknown database `xx` in catalog 'default'
select * from xx.yy;

0 comments on commit 3a50f2c

Please sign in to comment.