-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(python): add capability to read unity catalog (uc://) uris #3113
base: main
Are you sure you want to change the base?
Conversation
ACTION NEEDED delta-rs follows the Conventional Commits specification for release automation. The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
8fcd7f4
to
0824abe
Compare
/// Allow http url (e.g. http://localhost:8080/api/2.1/...) | ||
/// Supported keys: | ||
/// - `unity_allow_http_url` | ||
AllowHttpUrl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows users to work with a local (non-https) Unity Catalog REST API with delta-rs
.
0da4600
to
faf9ba9
Compare
faf9ba9
to
1a810d9
Compare
@ion-elgreco I've updated this PR to include the temp credentials functionality from PR #3078. Cheers. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3113 +/- ##
==========================================
- Coverage 72.10% 72.00% -0.10%
==========================================
Files 138 138
Lines 45320 45414 +94
Branches 45320 45414 +94
==========================================
+ Hits 32678 32701 +23
- Misses 10567 10635 +68
- Partials 2075 2078 +3 ☔ View full report in Codecov by Sentry. |
1a810d9
to
2fdb6e2
Compare
@omkar-foss looks good from my side! @hntd187 can you please also take a look. Specifically on whether the credentials need to be refreshed as part of the objectstore? Does UC also support writing temp credentials? |
I'll need to add a few python tests for this flow, will add tomorrow and then if all good, I suppose we can merge it. Also please note, the current UC REST integration that we have is more fine-tuned for Databricks Unity Catalog. The Unity Catalog OSS has slightly different response payloads for some APIs. e.g. Generate Temp Credentials API returns I can look into supporting OSS UC smoothly in a separate PR after this one. Cheers. |
@omkar-foss we could add an integration test with OSS version to catch these things essier |
Yes good idea! I'll add a failing test for Temp Creds API with the UC OSS JSON payload along with some other python tests. |
This adds capability to read directly from uc:// uris using the local catalog-unity crate. This also exposes the UC temporary credentials in storage_options of the `DeltaTable` instance so polars or similar readers can use it. Signed-off-by: Omkar P <[email protected]>
Signed-off-by: Omkar P <[email protected]>
2fdb6e2
to
a904e9a
Compare
Hi, I've added python integration tests for both UC Databricks and UC OSS with their respective mock payloads. Using mockoon as a mock HTTP server in GitHub Actions for the integration tests. |
Why not with the actual UC server? |
Since I had to anyway add a mock server for the UC Databricks integration test, thought might as well use it for UC OSS test to keep it simple, since we're testing only 2 UC REST APIs (Temp Credentials and Get Table Details). Let me know if you foresee a strong use case for adding the actual UC OSS server, if so, I'll add it here :) |
Signed-off-by: Omkar P <[email protected]>
6e482cc
to
734d4cb
Compare
Let's give @hntd187 some time to give a final look, otherwise we can merge end of the week |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly good, I'd like this to not panic, instead returning errors
crates/catalog-unity/src/lib.rs
Outdated
temp_creds.get_credentials().unwrap() | ||
} | ||
TableTempCredentialsResponse::Error(_error) => { | ||
panic!("Unable to get temporary credentials from Unity Catalog.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think being unable to get temp creds should result in a panic, perhaps a nice error result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
crates/catalog-unity/src/lib.rs
Outdated
) -> Result<(String, HashMap<String, String>), UnityCatalogError> { | ||
let uri_parts: Vec<&str> = table_uri[5..].split('.').collect(); | ||
if uri_parts.len() != 3 { | ||
panic!("Invalid Unity Catalog URI: {}", table_uri); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return an error instead of panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
crates/catalog-unity/src/lib.rs
Outdated
let database_name = uri_parts[1]; | ||
let table_name = uri_parts[2]; | ||
|
||
let unity_catalog = match UnityCatalogBuilder::from_env().build() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use ?
operator instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, done
crates/catalog-unity/src/lib.rs
Outdated
.get_table_storage_location(Some(catalog_id.to_string()), database_name, table_name) | ||
.await | ||
{ | ||
Ok(s) => s, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
crates/catalog-unity/src/lib.rs
Outdated
)); | ||
|
||
let (table_path, temp_creds) = match result { | ||
Ok(tup) => tup, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
crates/catalog-unity/src/lib.rs
Outdated
|
||
let mut storage_options = options.0.clone(); | ||
|
||
if !temp_creds.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it matter if it's empty? extend
should work on an empty collection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, silly me, thanks for this. Done.
Signed-off-by: Omkar P <[email protected]>
Thanks for your review, Steve. I've updated the PR as per your comments. |
Signed-off-by: Omkar P <[email protected]>
@omkar-foss can you add an integration page to the docs? :) |
.await?; | ||
let credentials = match temp_creds_res { | ||
TableTempCredentialsResponse::Success(temp_creds) => { | ||
temp_creds.get_credentials().unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed an error case here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one more error case nit :)
Description
This adds capability to read directly from uc:// uris using the local catalog-unity crate. This also exposes the UC temporary credentials in storage_options of the
DeltaTable
instance so polars or similar readers can use it.Related Issue(s)
Documentation
N/A