Skip to content

Commit 828bc04

Browse files
nkvuongnfx
andauthored
Fix Table ACL migration logic (#1149)
## Changes Fixed logic where list of grants are not reset between table iteration. Also updated tests to catch these issues ### Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] manually tested - [x] added unit tests - [ ] verified on staging environment (screenshot attached) Co-authored-by: Serge Smertin <[email protected]>
1 parent f7058bc commit 828bc04

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ def migrate_tables(self, *, what: What | None = None, acl_strategy: list[AclMigr
8484
self._init_seen_tables()
8585
tables_to_migrate = self._tm.get_tables_to_migrate(self._tc)
8686
tasks = []
87-
grants = []
8887
if acl_strategy is not None:
8988
grants_to_migrate = self._gc.snapshot()
9089
migrated_groups = self._group.snapshot()
9190
else:
9291
acl_strategy = []
9392
for table in tables_to_migrate:
93+
grants = []
9494
if what is not None and table.src.what != what:
9595
continue
9696
if AclMigrationWhat.LEGACY_TACL in acl_strategy:

tests/unit/hive_metastore/test_table_migrate.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,14 @@ def test_migrate_acls_should_produce_proper_queries(ws, caplog):
631631
table_migrate.migrate_tables(acl_strategy=[AclMigrationWhat.LEGACY_TACL])
632632

633633
assert "GRANT SELECT ON TABLE ucx_default.db1_dst.managed_dbfs TO `account group`" in backend.queries
634+
assert "GRANT MODIFY ON TABLE ucx_default.db1_dst.managed_dbfs TO `account group`" not in backend.queries
635+
assert "ALTER TABLE ucx_default.db1_dst.managed_dbfs OWNER TO `account group`" not in backend.queries
634636
assert "GRANT MODIFY ON TABLE ucx_default.db1_dst.managed_mnt TO `account group`" in backend.queries
637+
assert "GRANT SELECT ON TABLE ucx_default.db1_dst.managed_mnt TO `account group`" not in backend.queries
635638
assert "ALTER TABLE ucx_default.db1_dst.managed_other OWNER TO `account group`" in backend.queries
639+
assert "GRANT SELECT ON TABLE ucx_default.db1_dst.managed_other TO `account group`" not in backend.queries
640+
assert "GRANT MODIFY ON TABLE ucx_default.db1_dst.managed_other TO `account group`" not in backend.queries
636641
assert "GRANT SELECT ON VIEW ucx_default.db1_dst.view_dst TO `account group`" in backend.queries
642+
assert "GRANT MODIFY ON VIEW ucx_default.db1_dst.view_dst TO `account group`" not in backend.queries
637643

638644
assert "Cannot identify UC grant" in caplog.text

0 commit comments

Comments
 (0)