-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use table ownership heuristics for migrating ACLs
This PR prepends `OWN` grants when migrating ACLs for tables. For detailed logic on ownership heuristics, see #3066
- Loading branch information
Showing
3 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from unittest.mock import create_autospec | ||
|
||
from databricks.labs.ucx.hive_metastore.grants import Grant | ||
from databricks.labs.ucx.hive_metastore.ownership import TableOwnership, TableOwnershipGrantLoader | ||
from databricks.labs.ucx.hive_metastore.tables import Table, TablesCrawler | ||
|
||
|
||
def test_table_ownership_grants(): | ||
tables_crawler = create_autospec(TablesCrawler) | ||
tables_crawler.snapshot.return_value = [ | ||
Table( | ||
catalog='a', | ||
database='b', | ||
name='c', | ||
object_type='EXTERNAL', | ||
table_format='PARQUET', | ||
), | ||
Table( | ||
catalog='b', | ||
database='c', | ||
name='d', | ||
object_type='VIEW', | ||
table_format='...', | ||
view_text='...', | ||
), | ||
] | ||
table_ownership = create_autospec(TableOwnership) | ||
table_ownership.owner_of.return_value = 'somebody' | ||
|
||
loader = TableOwnershipGrantLoader(tables_crawler, table_ownership) | ||
|
||
grants = list(loader.load()) | ||
|
||
assert grants == [ | ||
Grant( | ||
principal='somebody', | ||
action_type='OWN', | ||
catalog='a', | ||
database='b', | ||
table='c', | ||
), | ||
Grant( | ||
principal='somebody', | ||
action_type='OWN', | ||
catalog='b', | ||
database='c', | ||
view='d', | ||
), | ||
] |