Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion python/ray/data/_internal/datasource/uc_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ def _set_env(self):
env_vars["AWS_DEFAULT_REGION"] = self.region
elif "azuresasuri" in creds:
env_vars["AZURE_STORAGE_SAS_TOKEN"] = creds["azuresasuri"]
# Azure UC returns a user delegation SAS; see
# https://docs.databricks.com/en/data-governance/unity-catalog/credential-vending.html
elif "azure_user_delegation_sas" in creds:
azure = creds["azure_user_delegation_sas"] or {}
sas_token = (
azure.get("sas_token")
or azure.get("sas")
or azure.get("token")
or azure.get("sasToken")
Comment on lines +89 to +92
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this varying?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support multiple versions of Azure UC, which apparently had changed the response key.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add release test for this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)
if sas_token and sas_token.startswith("?"):
sas_token = sas_token[1:]
if sas_token:
env_vars["AZURE_STORAGE_SAS_TOKEN"] = sas_token
if azure.get("storage_account"):
env_vars.setdefault("AZURE_STORAGE_ACCOUNT", azure["storage_account"])
env_vars.setdefault(
"AZURE_STORAGE_ACCOUNT_NAME", azure["storage_account"]
)
elif "gcp_service_account" in creds:
gcp_json = creds["gcp_service_account"]
temp_file = tempfile.NamedTemporaryFile(
Expand All @@ -95,8 +114,10 @@ def _set_env(self):
self._gcp_temp_file = temp_file.name
atexit.register(self._cleanup_gcp_temp_file, temp_file.name)
else:
known_keys = ", ".join(creds.keys())
raise ValueError(
"No known credential type found in Databricks UC response."
"No known credential type found in Databricks UC response. "
f"Available keys: {known_keys}"
)

for k, v in env_vars.items():
Expand Down