-
Notifications
You must be signed in to change notification settings - Fork 7
[DOP-29492] Implement Iceberg.DelegatedWarehouse #413
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Implement ``Iceberg.DelegatedWarehouse`` allowing to use vended S3 credentials or remote-signing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ Iceberg | |
|
|
||
| warehouse_filesystem | ||
| warehouse_s3 | ||
| warehouse_delegated | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
docs/connection/db_connection/iceberg/warehouse_delegated.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .. _iceberg-warehouse-delegated: | ||
|
|
||
| Delegated Warehouse | ||
| =================== | ||
|
|
||
| .. currentmodule:: onetl.connection.db_connection.iceberg.warehouse.delegated | ||
|
|
||
| .. autoclass:: IcebergDelegatedWarehouse | ||
| :members: get_packages, get_config | ||
| :member-order: bysource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
onetl/connection/db_connection/iceberg/warehouse/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| # SPDX-FileCopyrightText: 2021-2024 MTS PJSC | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| from onetl.connection.db_connection.iceberg.warehouse.base import IcebergWarehouse | ||
| from onetl.connection.db_connection.iceberg.warehouse.delegated import ( | ||
| IcebergDelegatedWarehouse, | ||
| ) | ||
| from onetl.connection.db_connection.iceberg.warehouse.filesystem import ( | ||
| IcebergFilesystemWarehouse, | ||
| ) | ||
| from onetl.connection.db_connection.iceberg.warehouse.s3 import ( | ||
| IcebergS3Warehouse, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "IcebergDelegatedWarehouse", | ||
| "IcebergFilesystemWarehouse", | ||
| "IcebergS3Warehouse", | ||
| "IcebergWarehouse", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
onetl/connection/db_connection/iceberg/warehouse/delegated.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # SPDX-FileCopyrightText: 2021-2024 MTS PJSC | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any, Dict, Optional | ||
|
|
||
| from typing_extensions import Literal | ||
|
|
||
| from onetl.hooks import slot, support_hooks | ||
|
|
||
| try: | ||
| from pydantic.v1 import Field | ||
| except (ImportError, AttributeError): | ||
| from pydantic import Field # type: ignore[no-redef, assignment] | ||
|
|
||
| from onetl._util.spark import stringify | ||
| from onetl.connection.db_connection.iceberg.warehouse import IcebergWarehouse | ||
| from onetl.impl.frozen_model import FrozenModel | ||
|
|
||
|
|
||
| @support_hooks | ||
| class IcebergDelegatedWarehouse(IcebergWarehouse, FrozenModel): | ||
| """Delegate configuring Iceberg warehouse to Iceberg catalog. |support_hooks| | ||
|
|
||
| Used by some Iceberg catalog implementations like: | ||
| * `Lakekeeper <https://docs.lakekeeper.io/docs/latest/storage/#s3>`_ | ||
| * `Polaris <https://polaris.apache.org/in-dev/unreleased/polaris-spark-client/>`_ | ||
| * `Apache Gravitino <https://gravitino.apache.org/docs/1.0.0/security/credential-vending/>`_ | ||
| * `Databricks Unity Catalog <https://docs.databricks.com/aws/en/external-access/iceberg#use-iceberg-tables-with-apache-spark>`_ | ||
|
|
||
| .. versionadded:: 0.14.1 | ||
|
|
||
| Parameters | ||
| ---------- | ||
| name : str, optional | ||
| Warehouse name/alias, if supported by specific Iceberg catalog | ||
|
|
||
| access_delegation : "vended-credentials" | "remote-signing" | ||
| Value of `X-Iceberg-Access-Delegation <https://github.com/apache/iceberg/blob/apache-iceberg-1.10.0/open-api/rest-catalog-open-api.yaml#L1854>`_ header. | ||
|
|
||
| extra : Dict[str, str], default: {} | ||
| Additional configuration parameters | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
||
| .. tabs:: | ||
|
|
||
| .. code-tab:: python S3 client with vended credentials | ||
|
|
||
| from onetl.connection import Iceberg | ||
|
|
||
| warehouse = Iceberg.DeletatedWarehouse( | ||
| name="my-warehouse", | ||
| access_delegation="vended-credentials", | ||
| # other params passed to S3 client (optional) | ||
| extra={"client.region": "us-east-1"}, | ||
| ) | ||
|
|
||
| .. code-tab:: python S3 client with remote signing | ||
|
|
||
| from onetl.connection import Iceberg | ||
|
|
||
| warehouse = Iceberg.DeletatedWarehouse( | ||
| name="my-warehouse", | ||
| access_delegation="remote-signing", | ||
| # other params passed to S3 client (optional) | ||
| extra={"client.region": "us-east-1"}, | ||
| ) | ||
| """ | ||
|
|
||
| name: Optional[str] = None | ||
| access_delegation: Literal["vended-credentials", "remote-signing"] | ||
| extra: Dict[str, Any] = Field(default_factory=dict) | ||
|
|
||
| @slot | ||
| def get_config(self) -> dict[str, str]: | ||
| config = { | ||
| "warehouse": self.name, | ||
| "header.X-Iceberg-Access-Delegation": self.access_delegation, | ||
| **stringify(self.extra), | ||
| } | ||
| return {k: v for k, v in config.items() if v is not None} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.