Skip to content

Commit

Permalink
[SPARK-46393][SQL][FOLLOWUP] Classify exceptions in JDBCTableCatalog.…
Browse files Browse the repository at this point in the history
…loadTable

### What changes were proposed in this pull request?

This is a followup of #44335 , which missed to handle `loadTable`

### Why are the changes needed?

better error message

### Does this PR introduce _any_ user-facing change?

no

### How was this patch tested?

existing test

### Was this patch authored or co-authored using generative AI tooling?

no

Closes #46905 from cloud-fan/jdbc.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Kent Yao <yao@apache.org>
  • Loading branch information
cloud-fan authored and yaooqinn committed Jun 7, 2024
1 parent 56b9b13 commit 82b4ad2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,11 @@
"List namespaces."
]
},
"LOAD_TABLE" : {
"message" : [
"Load the table <tableName>."
]
},
"NAMESPACE_EXISTS" : {
"message" : [
"Check that the namespace <namespace> exists."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,16 @@ class JDBCTableCatalog extends TableCatalog
checkNamespace(ident.namespace())
val optionsWithTableName = new JDBCOptions(
options.parameters + (JDBCOptions.JDBC_TABLE_NAME -> getTableName(ident)))
try {
JdbcUtils.classifyException(
errorClass = "FAILED_JDBC.LOAD_TABLE",
messageParameters = Map(
"url" -> options.getRedactUrl(),
"tableName" -> toSQLId(ident)),
dialect,
description = s"Failed to load table: $ident"
) {
val schema = JDBCRDD.resolveTable(optionsWithTableName)
JDBCTable(ident, schema, optionsWithTableName)
} catch {
case e: SQLException =>
logWarning("Failed to load table", e)
throw QueryCompilationErrors.noSuchTableError(ident)
}
}

Expand Down

0 comments on commit 82b4ad2

Please sign in to comment.