Skip to content

Commit 20c8379

Browse files
committed
Use CatalogType instead of SecurableTyoe
SecurableType is removed databricks/databricks-sdk-py#880 and CatalogType allows us to skip system catalogs too
1 parent 51a1e0f commit 20c8379

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from databricks.labs.lsql.backends import SqlBackend
88
from databricks.sdk import WorkspaceClient
99
from databricks.sdk.errors import DatabricksError, NotFound
10-
from databricks.sdk.service.catalog import CatalogInfo, CatalogInfoSecurableKind, SchemaInfo
10+
from databricks.sdk.service.catalog import CatalogInfo, CatalogType, SchemaInfo
1111

1212
from databricks.labs.ucx.framework.crawlers import CrawlerBase
1313
from databricks.labs.ucx.framework.utils import escape_sql_identifier
@@ -79,10 +79,9 @@ class TableMigrationStatusRefresher(CrawlerBase[TableMigrationStatus]):
7979
properties for the presence of the marker.
8080
"""
8181

82-
_skip_catalog_securable_kinds = [
83-
CatalogInfoSecurableKind.CATALOG_INTERNAL,
84-
CatalogInfoSecurableKind.CATALOG_SYSTEM,
85-
]
82+
_skip_catalog_types = {
83+
CatalogType.SYSTEM_CATALOG,
84+
}
8685

8786
def __init__(self, ws: WorkspaceClient, sql_backend: SqlBackend, schema, tables_crawler: TablesCrawler):
8887
super().__init__(sql_backend, "hive_metastore", schema, "migration_status", TableMigrationStatus)
@@ -163,7 +162,7 @@ def _try_fetch(self) -> Iterable[TableMigrationStatus]:
163162
def _iter_catalogs(self) -> Iterable[CatalogInfo]:
164163
try:
165164
for catalog in self._ws.catalogs.list():
166-
if catalog.securable_kind in self._skip_catalog_securable_kinds:
165+
if catalog.catalog_type in self._skip_catalog_types:
167166
continue
168167
yield catalog
169168
except DatabricksError as e:

tests/unit/hive_metastore/test_table_migration_status.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
from databricks.sdk import WorkspaceClient
66
from databricks.sdk.errors import BadRequest, DatabricksError, NotFound
7-
from databricks.sdk.service.catalog import CatalogInfoSecurableKind, CatalogInfo, SchemaInfo, TableInfo
7+
from databricks.sdk.service.catalog import CatalogInfo, CatalogType, SchemaInfo, TableInfo
88

99
from databricks.labs.ucx.hive_metastore.tables import TablesCrawler
1010
from databricks.labs.ucx.hive_metastore.table_migration_status import TableMigrationStatusRefresher
@@ -67,20 +67,12 @@ def test_table_migration_status_refresher_get_seen_tables_handles_errors_on_tabl
6767
tables_crawler.snapshot.assert_not_called()
6868

6969

70-
@pytest.mark.parametrize(
71-
"securable_kind",
72-
[
73-
CatalogInfoSecurableKind.CATALOG_INTERNAL,
74-
CatalogInfoSecurableKind.CATALOG_SYSTEM,
75-
],
76-
)
77-
def test_table_migration_status_refresher_get_seen_tables_skips_builtin_catalog(
78-
mock_backend, securable_kind: CatalogInfoSecurableKind
79-
) -> None:
70+
def test_table_migration_status_refresher_get_seen_tables_skips_system_catalog(mock_backend) -> None:
71+
"""We can skip the system catalog when refreshing the table migration status."""
8072
ws = create_autospec(WorkspaceClient)
8173
ws.catalogs.list.return_value = [
8274
CatalogInfo(name="test"),
83-
CatalogInfo(name="system", securable_kind=securable_kind),
75+
CatalogInfo(name="system", catalog_type=CatalogType.SYSTEM_CATALOG),
8476
]
8577

8678
def schemas_list(catalog_name: str) -> Iterable[SchemaInfo]:

0 commit comments

Comments
 (0)