Skip to content

Commit 82b4ad2

Browse files
cloud-fanyaooqinn
authored andcommitted
[SPARK-46393][SQL][FOLLOWUP] Classify exceptions in JDBCTableCatalog.loadTable
### What changes were proposed in this pull request? This is a followup of apache#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 apache#46905 from cloud-fan/jdbc. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Kent Yao <[email protected]>
1 parent 56b9b13 commit 82b4ad2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

common/utils/src/main/resources/error/error-conditions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,11 @@
12551255
"List namespaces."
12561256
]
12571257
},
1258+
"LOAD_TABLE" : {
1259+
"message" : [
1260+
"Load the table <tableName>."
1261+
]
1262+
},
12581263
"NAMESPACE_EXISTS" : {
12591264
"message" : [
12601265
"Check that the namespace <namespace> exists."

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalog.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,16 @@ class JDBCTableCatalog extends TableCatalog
131131
checkNamespace(ident.namespace())
132132
val optionsWithTableName = new JDBCOptions(
133133
options.parameters + (JDBCOptions.JDBC_TABLE_NAME -> getTableName(ident)))
134-
try {
134+
JdbcUtils.classifyException(
135+
errorClass = "FAILED_JDBC.LOAD_TABLE",
136+
messageParameters = Map(
137+
"url" -> options.getRedactUrl(),
138+
"tableName" -> toSQLId(ident)),
139+
dialect,
140+
description = s"Failed to load table: $ident"
141+
) {
135142
val schema = JDBCRDD.resolveTable(optionsWithTableName)
136143
JDBCTable(ident, schema, optionsWithTableName)
137-
} catch {
138-
case e: SQLException =>
139-
logWarning("Failed to load table", e)
140-
throw QueryCompilationErrors.noSuchTableError(ident)
141144
}
142145
}
143146

0 commit comments

Comments
 (0)