Repository navigation
Add new Unity catalog implementation with Delta Lake and Iceberg support - #115879
Conversation
|
Workflow [PR], commit [6434dfc] Summary: ✅
AI ReviewSummaryThis PR adds a new PR Metadata
Findings
Tests
Final Verdict
LLVM Coverage ReportMeasured on commit 6434dfc.
Changed lines: Changed C/C++ lines covered: 436/563 (77.44%) · Uncovered code |
Build profile diff (arm_release)Commit See the job log for details. |
|
|
Never mind, it is getting overly complicated. I will skip the test for this PR. |
| /// Databricks OIDC expects `all-apis`; the default `auth_scope` value targets Iceberg REST catalogs. | ||
| const std::string unity_auth_scope = settings[DatabaseDataLakeSetting::auth_scope].changed | ||
| ? settings[DatabaseDataLakeSetting::auth_scope].value | ||
| : "all-apis"; |
There was a problem hiding this comment.
just
const std::string unity_auth_scope = settings[DatabaseDataLakeSetting::auth_scope].value
There was a problem hiding this comment.
The default value is PRINCIPAL_ROLE:ALL, which is correct for REST catalogs, but not for the Unity catalog. So we do need to set the default here.
| return json.dumps(body).encode() | ||
|
|
||
|
|
||
| class Handler(BaseHTTPRequestHandler): |
There was a problem hiding this comment.
The OSS server used in tests has some differences from the actual Databricks server. There's a comment at the top of the file that summarizes the differences:
"""Makes the open-source Unity Catalog server look like Databricks to
`UnityV2Catalog`, for the tables in `UNIFORM_TABLES` only:
- serves the Iceberg REST catalog at `/iceberg-rest`, not `/iceberg`;
- reports an Iceberg `securable_kind`, which the open-source server never sends;
- writes the table location as `file:///tmp/...`, which `setLocation` requires.
It also emulates Databricks authentication:
- `POST /oidc/v1/token` mints OAuth tokens for `CLIENT_ID:CLIENT_SECRET`, and
requires `scope=all-apis` as Databricks service principals do;
- every proxied route requires `Authorization: Bearer <token>`, where the token
is either `PAT_TOKEN` or a minted OAuth token, and replies 401 otherwise;
- `/control/*` endpoints let the test expire tokens.
"""
| }); | ||
| } | ||
|
|
||
| return tryGetDeltaTableMetadata(full_table_name, object, result); |
There was a problem hiding this comment.
why do we have retries for iceberg but don't have for delta?
There was a problem hiding this comment.
tryGetDeltaTableMetadata only parses the JSON, it does not make any HTTP requests. For Iceberg, we do need to make a second request to get metadata for Iceberg tables. The retry refreshes the OAuth token if needed (it's not a generic retry).
| return f"{prefix}_{uuid.uuid4()}".replace("-", "_") | ||
|
|
||
|
|
||
| def create_database(node, db_name, url=UC_URL, catalog_credential=None): |
There was a problem hiding this comment.
The auth coverage here still never exercises the auth_header mode that UnityV2Catalog now supports.
create_database only injects catalog_credential, and the tests below cover PAT and OAuth through that path, but not auth_header = 'Authorization: Bearer ...'. That leaves the third advertised auth mode unproven end-to-end, including forwarding the header into the embedded Iceberg REST client for SHOW CREATE / reads on the Iceberg arm.
Please add one proxied case that creates the database with auth_header (no catalog_credential) and reads marksheet_uniform, so a regression in the header-only path does not slip through.
| SettingsChanges catalog_settings_changes; | ||
| for (const auto & change : settings_changes) | ||
| { | ||
| if (change.name != "use_unity_catalog_v2") |
There was a problem hiding this comment.
let's move "use_unity_catalog_v2" to some static constexpr const char* variable
There was a problem hiding this comment.
Good catch. I wanted to remove the harded-coded copy altogethrer, so I went a bit further and added a call to DB::DatabaseDataLakeSettings::getSettingName(DB::DatabaseDataLakeSetting::use_unity_catalog_v2).
|
|
||
| /// UniForm ("DELTA_UNIFORM_ICEBERG") is a Delta table that also publishes Iceberg metadata; | ||
| /// read it as Delta because the Delta log is the source of truth. | ||
| static const std::unordered_set<std::string> READABLE_DELTA_FORMATS = {"DELTA", "DELTA_UNIFORM_ICEBERG"}; |
There was a problem hiding this comment.
Don't we need also "ICEBERG" here?
There was a problem hiding this comment.
No, the idea is that this shows which formats should be read as Delta instead of Iceberg. I'll change the comment / naming to make it clear.
|
|
||
| Poco::JSON::Object request_body; | ||
| request_body.set("table_id", table_id); | ||
| request_body.set("operation", "READ"); |
There was a problem hiding this comment.
It copies the behavior in the V1 catalog.
We'll need to change it to READ_WRITE for inserts to work, but this PR is already big, so I would prefer to handle in a separate PR.
(Will add clarifying comment.)
| auto catalog = std::make_shared<RestCatalog>( | ||
| warehouse, | ||
| iceberg_rest_url, | ||
| /* catalog_credential= */ "", |
There was a problem hiding this comment.
don't we need to get those values from the settings?
There was a problem hiding this comment.
UnityV2Catalog already takes these values and uses them to create the auth_header.
I'll add a clarifying comment.
| @@ -0,0 +1,642 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
Let's also add a test that we can
- create iceberg table
- write something into this table
There was a problem hiding this comment.
I'll add it for Delta. It doesn't yet support CREATE / INSERT for Iceberg, will add test to show it fails with NOT_IMPLEMENTED.
There was a problem hiding this comment.
is it hard to support? I think it could be confusing that we can write into delta and can't write into iceberg
There was a problem hiding this comment.
Ok, I added support. I ran manual tests and added them to the summary.
Unfortunately, difficult to add to the integration test since the OSS catalog doesn't support the POST endpoints.
Antalya 26.8: Backport of ClickHouse#115879 Unity catalog(v2)
Changelog category (leave one):
Changelog entry:
Added a new implementation of the
unitycatalog type in theDataLakeCatalogdatabase engine. It serves both Delta Lake and Iceberg tables from a single Unity Catalog, detecting the format of each table and routing Iceberg tables through the Unity Catalog Iceberg REST endpoint. Enable it with the database settinguse_unity_catalog_v2, or set the session setting of the same name beforeCREATE DATABASE. Switch an existing database withALTER DATABASE ... MODIFY SETTING use_unity_catalog_v2 = 1.Summary
Add a new implementation of the "unity" catalog. It supports both Delta and Iceberg tables, in contrast to the current implementation, which only supports Delta. The new implementation is behind the
use_unity_catalog_v2database setting, so existing databases keep the old behavior. After a release or two, we can make it the default.Credit to @melvynator for the prototype in #100669.
Tests
Added integration tests. Also, ran manual tests. I first created the following tables in Databricks.
Then created the following databases:
For each database, I ran the following queries and verified expected results:
Also verified that CREATE still works for Delta and that CREATE / INSERT / UPDATE work for Iceberg.
Workflow [PR]
Sync PR [sync-upstream/pr/115879]
Version info
26.10.1.568-master(included in26.10and later)