|
| 1 | +import logging |
1 | 2 | from collections.abc import Iterator |
2 | 3 | from dataclasses import dataclass |
3 | 4 | from functools import partial |
|
6 | 7 | from databricks.labs.ucx.framework.parallel import ThreadedExecution |
7 | 8 | from databricks.labs.ucx.hive_metastore.tables import TablesCrawler |
8 | 9 |
|
| 10 | +logger = logging.getLogger(__name__) |
| 11 | + |
9 | 12 |
|
10 | 13 | @dataclass(frozen=True) |
11 | 14 | class Grant: |
@@ -219,20 +222,24 @@ def _grants( |
219 | 222 | any_file=any_file, |
220 | 223 | anonymous_function=anonymous_function, |
221 | 224 | ) |
222 | | - object_type_normalization = {"SCHEMA": "DATABASE", "CATALOG$": "CATALOG"} |
223 | | - for row in self._fetch(f"SHOW GRANTS ON {on_type} {key}"): |
224 | | - (principal, action_type, object_type, _) = row |
225 | | - if object_type in object_type_normalization: |
226 | | - object_type = object_type_normalization[object_type] |
227 | | - if on_type != object_type: |
228 | | - continue |
229 | | - yield Grant( |
230 | | - principal=principal, |
231 | | - action_type=action_type, |
232 | | - table=table, |
233 | | - view=view, |
234 | | - database=database, |
235 | | - catalog=catalog, |
236 | | - any_file=any_file, |
237 | | - anonymous_function=anonymous_function, |
238 | | - ) |
| 225 | + try: |
| 226 | + object_type_normalization = {"SCHEMA": "DATABASE", "CATALOG$": "CATALOG"} |
| 227 | + for row in self._fetch(f"SHOW GRANTS ON {on_type} {key}"): |
| 228 | + (principal, action_type, object_type, _) = row |
| 229 | + if object_type in object_type_normalization: |
| 230 | + object_type = object_type_normalization[object_type] |
| 231 | + if on_type != object_type: |
| 232 | + continue |
| 233 | + yield Grant( |
| 234 | + principal=principal, |
| 235 | + action_type=action_type, |
| 236 | + table=table, |
| 237 | + view=view, |
| 238 | + database=database, |
| 239 | + catalog=catalog, |
| 240 | + any_file=any_file, |
| 241 | + anonymous_function=anonymous_function, |
| 242 | + ) |
| 243 | + except RuntimeError as e: |
| 244 | + logger.error(f"Couldn't fetch grants for object {on_type} {key}: {e}") |
| 245 | + return [] |
0 commit comments