Skip to content

Commit 4ed2554

Browse files
authored
Fixed Unknown: org.apache.hadoop.hive.ql.metadata.HiveException: NoSuchObjectException in crawl_grants task by ignoring the database that is not found (#967)
1 parent d1fdd9d commit 4ed2554

File tree

1 file changed

+11
-7
lines changed
  • src/databricks/labs/ucx/hive_metastore

1 file changed

+11
-7
lines changed

src/databricks/labs/ucx/hive_metastore/udfs.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from functools import partial
55

66
from databricks.labs.blueprint.parallel import Threads
7+
from databricks.sdk.errors import Unknown
78

89
from databricks.labs.ucx.framework.crawlers import CrawlerBase, SqlBackend
910
from databricks.labs.ucx.framework.utils import escape_sql_identifier
@@ -66,13 +67,16 @@ def _crawl(self) -> Iterable[Udf]:
6667
# "target schema <database> is not in the current catalog"
6768
self._exec(f"USE CATALOG {escape_sql_identifier(catalog)};")
6869
for (database,) in self._all_databases():
69-
logger.debug(f"[{catalog}.{database}] listing udfs")
70-
for (udf,) in self._fetch(
71-
f"SHOW USER FUNCTIONS FROM {escape_sql_identifier(catalog)}.{escape_sql_identifier(database)};"
72-
):
73-
if udf.startswith(f"{catalog}.{database}"):
74-
udf_name = udf[udf.rfind(".") + 1 :] # remove catalog and database info from the name
75-
tasks.append(partial(self._describe, catalog, database, udf_name))
70+
try:
71+
logger.debug(f"[{catalog}.{database}] listing udfs")
72+
for (udf,) in self._fetch(
73+
f"SHOW USER FUNCTIONS FROM {escape_sql_identifier(catalog)}.{escape_sql_identifier(database)};"
74+
):
75+
if udf.startswith(f"{catalog}.{database}"):
76+
udf_name = udf[udf.rfind(".") + 1 :] # remove catalog and database info from the name
77+
tasks.append(partial(self._describe, catalog, database, udf_name))
78+
except Unknown as err:
79+
logger.error(f"Problem with {database}: {err}")
7680
catalog_tables, errors = Threads.gather(f"listing udfs in {catalog}", tasks)
7781
if len(errors) > 0:
7882
logger.error(f"Detected {len(errors)} while scanning udfs in {catalog}")

0 commit comments

Comments
 (0)