Skip to content

Commit 574aae1

Browse files
authored
Use CREATE_FOREIGN_CATALOG instead of CREATE_FOREIGN_SECURABLE with HMS federation enablement commands (#3309)
closes #3308
1 parent 136c536 commit 574aae1

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ classifiers = [
4444
"Topic :: Utilities",
4545
]
4646

47-
dependencies = ["databricks-sdk>=0.38,<0.39",
47+
dependencies = ["databricks-sdk>=0.39",
4848
"databricks-labs-lsql>=0.14.0,<0.15",
4949
"databricks-labs-blueprint>=0.9.1,<0.10",
5050
"PyYAML>=6.0.0,<7.0.0",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
ConnectionType,
99
ConnectionInfo,
1010
SecurableType,
11-
Privilege,
1211
PermissionsChange,
1312
CatalogInfo,
13+
Privilege,
1414
)
1515

1616
from databricks.labs.ucx.account.workspaces import WorkspaceInfo
@@ -101,8 +101,8 @@ def _get_authorized_paths(self) -> str:
101101

102102
def _add_missing_permissions_if_needed(self, location_name: str, current_user: str):
103103
grants = self._location_grants(location_name)
104-
if Privilege.CREATE_FOREIGN_CATALOG not in grants[current_user]:
105-
change = PermissionsChange(principal=current_user, add=[Privilege.CREATE_FOREIGN_CATALOG])
104+
if Privilege.CREATE_FOREIGN_SECURABLE not in grants[current_user]:
105+
change = PermissionsChange(principal=current_user, add=[Privilege.CREATE_FOREIGN_SECURABLE])
106106
self._workspace_client.grants.update(SecurableType.EXTERNAL_LOCATION, location_name, changes=[change])
107107

108108
def _location_grants(self, location_name: str) -> dict[str, set[Privilege]]:

tests/unit/hive_metastore/test_federation.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
ExternalLocationInfo,
1010
PermissionsList,
1111
PrivilegeAssignment,
12-
Privilege,
1312
SecurableType,
1413
PermissionsChange,
1514
ConnectionInfo,
@@ -19,7 +18,11 @@
1918
from databricks.labs.ucx.account.workspaces import WorkspaceInfo
2019
from databricks.labs.ucx.config import WorkspaceConfig
2120
from databricks.labs.ucx.hive_metastore import ExternalLocations
22-
from databricks.labs.ucx.hive_metastore.federation import HiveMetastoreFederation, HiveMetastoreFederationEnabler
21+
from databricks.labs.ucx.hive_metastore.federation import (
22+
HiveMetastoreFederation,
23+
HiveMetastoreFederationEnabler,
24+
Privilege,
25+
)
2326
from databricks.labs.ucx.hive_metastore.locations import ExternalLocation
2427

2528

@@ -62,13 +65,13 @@ def test_create_federated_catalog():
6265
call.update(
6366
SecurableType.EXTERNAL_LOCATION,
6467
'b',
65-
changes=[PermissionsChange(principal='serge', add=[Privilege.CREATE_FOREIGN_CATALOG])],
68+
changes=[PermissionsChange(principal='serge', add=[Privilege.CREATE_FOREIGN_SECURABLE])],
6669
),
6770
call.get(SecurableType.EXTERNAL_LOCATION, 'e'),
6871
call.update(
6972
SecurableType.EXTERNAL_LOCATION,
7073
'e',
71-
changes=[PermissionsChange(principal='serge', add=[Privilege.CREATE_FOREIGN_CATALOG])],
74+
changes=[PermissionsChange(principal='serge', add=[Privilege.CREATE_FOREIGN_SECURABLE])],
7275
),
7376
]
7477
assert calls == workspace_client.grants.method_calls

0 commit comments

Comments
 (0)