diff --git a/src/databricks/labs/ucx/hive_metastore/mapping.py b/src/databricks/labs/ucx/hive_metastore/mapping.py index 3a83abf41d..3aef32ba20 100644 --- a/src/databricks/labs/ucx/hive_metastore/mapping.py +++ b/src/databricks/labs/ucx/hive_metastore/mapping.py @@ -155,15 +155,8 @@ def unskip_table_or_view( self._sql_backend.execute( f"ALTER {table.kind} {escape_sql_identifier(table.full_name)} UNSET TBLPROPERTIES IF EXISTS('{self.UCX_SKIP_PROPERTY}');" ) - except NotFound as e: - if "[TABLE_OR_VIEW_NOT_FOUND]" in str(e) or "[DELTA_TABLE_NOT_FOUND]" in str(e): - logger.error( - f"Failed to remove skip marker from table: {schema_name}.{table_name}. Table not found.", exc_info=e - ) - else: - logger.error(f"Failed to remove skip marker from table: {schema_name}.{table_name}", exc_info=e) - except BadRequest as e: - logger.error(f"Failed to remove skip marker from table: {schema_name}.{table_name}: {e!s}", exc_info=e) + except (NotFound, BadRequest) as e: + logger.error(f"Failed to remove skip marker from table: {table.full_name}", exc_info=e) def skip_schema(self, schema: str): # Marks a schema to be skipped in the migration process by applying a table property @@ -189,12 +182,7 @@ def unskip_schema(self, schema: str) -> None: self._sql_backend.execute( f"ALTER SCHEMA hive_metastore.{escape_sql_identifier(schema)} UNSET DBPROPERTIES IF EXISTS('{self.UCX_SKIP_PROPERTY}');" ) - except NotFound as e: - if "[SCHEMA_NOT_FOUND]" in str(e): - logger.error(f"Failed to remove skip marker from schema: {schema}. Schema not found.", exc_info=e) - else: - logger.error(f"Failed to remove skip marker from schema: {schema}.", exc_info=e) - except BadRequest as e: + except (NotFound, BadRequest) as e: logger.error(f"Failed to remove skip marker from schema: {schema}.", exc_info=e) def get_tables_to_migrate(self, tables_crawler: TablesCrawler) -> Collection[TableToMigrate]: diff --git a/tests/unit/hive_metastore/test_mapping.py b/tests/unit/hive_metastore/test_mapping.py index f5913137a9..e0ac9f56ad 100644 --- a/tests/unit/hive_metastore/test_mapping.py +++ b/tests/unit/hive_metastore/test_mapping.py @@ -211,7 +211,7 @@ def test_skip_happy_path(caplog): assert len(caplog.records) == 0 -def test_unskip_on_table(): +def test_unskip_on_table() -> None: ws = create_autospec(WorkspaceClient) mock_backend = MockBackend() installation = MockInstallation() @@ -225,7 +225,7 @@ def test_unskip_on_table(): ) -def test_unskip_on_view(): +def test_unskip_on_view() -> None: ws = create_autospec(WorkspaceClient) mock_backend = MockBackend() installation = MockInstallation() @@ -241,7 +241,7 @@ def test_unskip_on_view(): ) -def test_unskip_on_schema(): +def test_unskip_on_schema() -> None: ws = create_autospec(WorkspaceClient) mock_backend = MockBackend() installation = MockInstallation() @@ -273,7 +273,7 @@ def test_unskip_badrequest(caplog) -> None: mapping = TableMapping(installation, ws, sbe) table = Table(catalog="catalog", database="schema", name="table", object_type="table", table_format="csv") mapping.unskip_table_or_view(schema_name="schema", table_name="table", load_table=lambda _schema, _table: table) - assert [rec.message for rec in caplog.records if "bad command" in rec.message.lower()] + assert [rec.message for rec in caplog.records if "failed to remove skip marker " in rec.message.lower()] ws.tables.get.assert_not_called()