Skip to content

Commit

Permalink
[SPARK-46417][SQL] Do not fail when calling hive.getTable and throwEx…
Browse files Browse the repository at this point in the history
…ception is false

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

Uses can set up their own HMS and let Spark connects to it. We have no control over it and somtimes it's not even Hive but just a HMS-API-compatible service.

Spark should be more fault-tolerant when calling HMS APIs. This PR fixes an issue in `hive.getTable` with `throwException = false`, to make sure we don't throw error when can't fetch the table.

### Why are the changes needed?

avoid query failure caused by HMS bugs.

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

No

### How was this patch tested?

in our product environment

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

No

Closes #44364 from cloud-fan/hive.

Lead-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
  • Loading branch information
2 people authored and yaooqinn committed Dec 15, 2023
1 parent d5d2c58 commit 5948803
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,13 @@ private[client] class Shim_v2_0 extends Shim with Logging {
tableName: String,
throwException: Boolean): Table = {
recordHiveCall()
val table = hive.getTable(dbName, tableName, throwException)
val table = try {
hive.getTable(dbName, tableName, throwException)
} catch {
// Hive may have bugs and still throw an exception even if `throwException` is false.
case e: HiveException if !throwException =>
null
}
if (table != null) {
table.getTTable.setTableName(tableName)
table.getTTable.setDbName(dbName)
Expand Down

0 comments on commit 5948803

Please sign in to comment.