Skip to content

Commit 3cfeb77

Browse files
authored
Fixed create federated catalog to add all external locations to the allowed paths. (#4387)
Fixed "create federated catalog" to scan all external locations and add their paths to the allowed paths for the federated catalog.
1 parent c3368ba commit 3cfeb77

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,28 +271,19 @@ def _get_or_create_glue_connection(self, name: str, aws_glue: AWSGlue, credentia
271271
return self._get_existing_connection(name)
272272

273273
def _get_authorized_paths(self) -> str:
274-
existing = {}
275-
for external_location in self._ws.external_locations.list():
276-
existing[external_location.url] = external_location
277274
authorized_paths = []
278275
current_user = self._ws.current_user.me()
279-
if not current_user.user_name:
280-
raise NotFound('Current user not found')
281-
# Get the external locations. If not using external HMS, include the root DBFS location.
282-
external_locations = self._external_locations.external_locations_with_root()
283-
284-
for external_location_info in external_locations:
285-
location = ExternalLocations.clean_location(external_location_info.location)
286-
existing_location = existing.get(location)
287-
if not existing_location:
288-
logger.warning(f'External location {location} not found')
276+
for external_location in self._ws.external_locations.list():
277+
if not external_location.url:
278+
logger.warning("Location with no URL.")
289279
continue
290-
location_name = existing_location.name
280+
location_name = external_location.name
291281
if not location_name:
292-
logger.warning(f'External location {location} has no name')
282+
logger.warning("Location with no name.")
293283
continue
294-
self._add_missing_permissions_if_needed(location_name, current_user.user_name)
295-
authorized_paths.append(location)
284+
authorized_paths.append(external_location.url)
285+
if current_user and current_user.user_name:
286+
self._add_missing_permissions_if_needed(location_name, current_user.user_name)
296287
return ",".join(authorized_paths)
297288

298289
def _add_missing_permissions_if_needed(self, location_name: str, current_user: str):

0 commit comments

Comments
 (0)