Skip to content

Commit

Permalink
Handle errors better in tables.scala (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgeorge-db committed Sep 21, 2023
1 parent cbc2654 commit 5b99e6d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/databricks/labs/ucx/hive_metastore/tables.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException
import org.apache.spark.sql.catalyst.catalog.{CatalogTable, CatalogTableType}
import org.apache.spark.sql.DataFrame

Expand All @@ -10,7 +11,13 @@ def metadataForAllTables(databases: Seq[String]): DataFrame = {

val externalCatalog = spark.sharedState.externalCatalog
databases.par.flatMap(databaseName => {
val tables = externalCatalog.listTables(databaseName)
val tables = try {
externalCatalog.listTables(databaseName)
} catch {
case err: NoSuchDatabaseException =>
println(s"[ERROR][${databaseName}] ignoring database because of ${err}")
null
}
if (tables == null) {
println(s"[WARN][${databaseName}] listTables returned null")
Seq()
Expand Down

0 comments on commit 5b99e6d

Please sign in to comment.