|
2 | 2 |
|
3 | 3 | import dataclasses
|
4 | 4 | import warnings
|
5 |
| -from typing import Callable |
| 5 | +from typing import Callable, Literal |
6 | 6 | from urllib.parse import urlparse
|
7 | 7 |
|
8 | 8 | import unitycatalog
|
@@ -91,14 +91,14 @@ def _paginated_list_tables(client: unitycatalog.Unitycatalog, page_token: str |
|
91 | 91 | return self._paginate_to_completion(_paginated_list_tables)
|
92 | 92 |
|
93 | 93 | def load_table(
|
94 |
| - self, table_name: str, new_table_storage_path: str | None = None, intent: str = "READ_WRITE" |
| 94 | + self, table_name: str, new_table_storage_path: str | None = None, mode: Literal["r"|"rw"] = "rw" |
95 | 95 | ) -> UnityCatalogTable:
|
96 | 96 | """Loads an existing Unity Catalog table. If the table is not found, and information is provided in the method to create a new table, a new table will be attempted to be registered.
|
97 | 97 |
|
98 | 98 | Args:
|
99 | 99 | table_name (str): Name of the table in Unity Catalog in the form of dot-separated, 3-level namespace
|
100 | 100 | new_table_storage_path (str, optional): Cloud storage path URI to register a new external table using this path. Unity Catalog will validate if the path is valid and authorized for the principal, else will raise an exception.
|
101 |
| - intent (str, optional): The intended use of the table, which impacts authorization. Defaults to "READ_WRITE", else can be "READ". |
| 101 | + mode (Literal["r", "rw"], optional): The intended use of the table, which impacts authorization. Defaults to "rw". |
102 | 102 |
|
103 | 103 | Returns:
|
104 | 104 | UnityCatalogTable
|
@@ -140,7 +140,8 @@ def load_table(
|
140 | 140 | table_id = table_info.table_id
|
141 | 141 | storage_location = table_info.storage_location
|
142 | 142 | # Grab credentials from Unity catalog and place it into the Table
|
143 |
| - temp_table_credentials = self._client.temporary_table_credentials.create(operation=intent, table_id=table_id) |
| 143 | + operation = "READ" if mode == "r" else "READ_WRITE" |
| 144 | + temp_table_credentials = self._client.temporary_table_credentials.create(operation=operation, table_id=table_id) |
144 | 145 |
|
145 | 146 | scheme = urlparse(storage_location).scheme
|
146 | 147 | if scheme == "s3" or scheme == "s3a":
|
|
0 commit comments