From 48022f4652a0e3400908bb3c2feedfdff78af86d Mon Sep 17 00:00:00 2001 From: Liran Bareket Date: Mon, 21 Oct 2024 13:48:00 -0400 Subject: [PATCH] Introduce and tested CLI --- src/databricks/labs/ucx/contexts/application.py | 1 - src/databricks/labs/ucx/hive_metastore/grants.py | 3 +-- tests/unit/hive_metastore/test_migrate_acls.py | 7 +++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/databricks/labs/ucx/contexts/application.py b/src/databricks/labs/ucx/contexts/application.py index 6729e31d06..8d768adfbf 100644 --- a/src/databricks/labs/ucx/contexts/application.py +++ b/src/databricks/labs/ucx/contexts/application.py @@ -275,7 +275,6 @@ def acl_migrator(self): self.migration_status_refresher, self.migrate_grants, self.sql_backend, - self.config.ucx_catalog, self.config.inventory_database, ) diff --git a/src/databricks/labs/ucx/hive_metastore/grants.py b/src/databricks/labs/ucx/hive_metastore/grants.py index b973232ce5..268cec2d5a 100644 --- a/src/databricks/labs/ucx/hive_metastore/grants.py +++ b/src/databricks/labs/ucx/hive_metastore/grants.py @@ -843,14 +843,13 @@ def __init__( migration_status_refresher: TableMigrationStatusRefresher, migrate_grants: MigrateGrants, backend: SqlBackend, - catalog: str, schema: str, ): self._table_crawler = tables_crawler self._workspace_info = workspace_info self._migration_status_refresher = migration_status_refresher self._migrate_grants = migrate_grants - super().__init__(backend, catalog, schema, "acls", Grant) + super().__init__(backend, "hive_metastore", schema, "acls", Grant) def migrate_acls(self, *, target_catalog: str | None = None, hms_fed: bool = False) -> None: workspace_name = self._workspace_info.current() diff --git a/tests/unit/hive_metastore/test_migrate_acls.py b/tests/unit/hive_metastore/test_migrate_acls.py index 3542244426..ec5697f956 100644 --- a/tests/unit/hive_metastore/test_migrate_acls.py +++ b/tests/unit/hive_metastore/test_migrate_acls.py @@ -35,7 +35,7 @@ def test_migrate_acls_should_produce_proper_queries(ws, ws_info, mock_backend, c migrate_grants = create_autospec(MigrateGrants) acl_migrate = ACLMigrator( - table_crawler, workspace_info, migration_status_refresher, migrate_grants, mock_backend, "hive_metastore", "ucx" + table_crawler, workspace_info, migration_status_refresher, migrate_grants, mock_backend, "ucx" ) migration_status_refresher.get_seen_tables.return_value = { "ucx_default.db1_dst.view_dst": "hive_metastore.db1_src.view_src", @@ -68,7 +68,6 @@ def test_migrate_acls_hms_fed_proper_queries(ws, ws_info, mock_backend, caplog): migration_status_refresher, migrate_grants, mock_backend, - "hive_metastore", "ucx", ) acl_migrate.migrate_acls(hms_fed=True, target_catalog='hms_fed') @@ -123,10 +122,10 @@ def grant_loader(): migration_status_refresher.index.return_value = migration_index acl_migrate = ACLMigrator( - table_crawler, workspace_info, migration_status_refresher, migrate_grants, sql_backend, "hive_metastore", "ucx" + table_crawler, workspace_info, migration_status_refresher, migrate_grants, sql_backend, "ucx" ) tacls = acl_migrate.snapshot() - sql_backend.fetch.assert_called_with('SELECT * FROM `hive_metastore`.`ucx`.`ACLS`') + sql_backend.fetch.assert_called_with('SELECT * FROM `hive_metastore`.`ucx`.`acls`') for grant in user_grants: assert grant in tacls assert Grant('acc_group1', 'SELECT', database='db1_src', table='table1') in tacls