Skip to content

Commit 2c4495e

Browse files
committed
fix: revise parameter added for unity read/write mode
1 parent 30125d0 commit 2c4495e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ When proposing features, please include:
2525

2626
To set up your development environment:
2727

28-
1. Ensure that your system has a suitable Python version installed (>=3.7, <=3.11)
28+
1. Ensure that your system has a suitable Python version installed (>=3.9, <=3.11)
2929
2. [Install the Rust compilation toolchain](https://www.rust-lang.org/tools/install)
3030
3. Clone the Daft repo: `git clone [email protected]:Eventual-Inc/Daft.git`
3131
4. Run `make .venv` from your new cloned Daft repository to create a new virtual environment with all of Daft's development dependencies installed

daft/unity_catalog/unity_catalog.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import dataclasses
44
import warnings
5-
from typing import Callable
5+
from typing import Callable, Literal
66
from urllib.parse import urlparse
77

88
import unitycatalog
@@ -91,14 +91,14 @@ def _paginated_list_tables(client: unitycatalog.Unitycatalog, page_token: str |
9191
return self._paginate_to_completion(_paginated_list_tables)
9292

9393
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"
9595
) -> UnityCatalogTable:
9696
"""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.
9797
9898
Args:
9999
table_name (str): Name of the table in Unity Catalog in the form of dot-separated, 3-level namespace
100100
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".
102102
103103
Returns:
104104
UnityCatalogTable
@@ -140,7 +140,8 @@ def load_table(
140140
table_id = table_info.table_id
141141
storage_location = table_info.storage_location
142142
# 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)
144145

145146
scheme = urlparse(storage_location).scheme
146147
if scheme == "s3" or scheme == "s3a":

0 commit comments

Comments
 (0)