Repository navigation
add delta lake to iceberg blueprint and IT #4103
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
derrickaw
merged 35 commits into
GoogleCloudPlatform:main
from
derrickaw:20260803_addDeltaLake2LHIT
Sep 5, 2026
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
66fc208
add delta lake to iceberg IT
derrickaw 92aadfa
fix spotless and rerun auto-generation
derrickaw 9caddc2
switch to interrupt call
derrickaw ece2e53
change to a dynamic import to fix error
derrickaw 58cc7cc
add forgotten yaml definition file
derrickaw 6f0eb7d
add generated README for DeltaLakeToIceberg template
derrickaw 353123c
switch back to stop method for direct runner
derrickaw 0b6fa4a
address gemini comment
derrickaw a9b0bcf
spotless
derrickaw 9fdced5
initial comments fixes
derrickaw ee83e6e
change iceberg to lakehouse
derrickaw 99d9dd5
change to a wrapped writetoiceberg via writetolakehouse
derrickaw 0dc18f3
update yaml file with wrapper transform
derrickaw e35c1d2
remove old writetolakehouse transform idea
derrickaw a0cf3b4
spotless
derrickaw a323e94
change to renamed transform
derrickaw bf3e10c
address Delta client comment
derrickaw f1580c4
spotless
derrickaw 498d496
Merge remote-tracking branch 'upstream/main' into 20260803_addDeltaLa…
derrickaw 3cfd16c
fix generated file
derrickaw 12f799e
create write to lakehouse
derrickaw aa73a25
change package
derrickaw a6e7bad
oops - used wrong assumed date
derrickaw f0e93b3
fix uri catalog version
derrickaw 1300f82
update jar to to be the same
derrickaw 6333399
change to managed and mimic deltalake
derrickaw ef2df8e
update one more version jar
derrickaw 5dd1cc4
add manifest resource transformer
derrickaw 86f5da5
add managed and iceberg
derrickaw 90c0458
change pattern
derrickaw b6f16a0
force to schemaAwareExternalTransform
derrickaw 8973be4
another try
derrickaw 655f3a8
add transformer
derrickaw 9e2ba6a
update per Cham's comments
derrickaw 1b084e9
fix formatting
derrickaw 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
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
72 changes: 72 additions & 0 deletions
72
python/src/main/python/job-builder-util-transforms/write_to_lakehouse.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,72 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Module containing transforms to write data to Lakehouse tables.""" | ||
|
|
||
| from typing import Iterable, Mapping, Optional | ||
| from apache_beam.transforms import PTransform | ||
| from apache_beam.yaml.yaml_io import write_to_iceberg | ||
|
|
||
|
|
||
| class WriteToLakehouse(PTransform): | ||
| """A PTransform that writes data to a Lakehouse table. | ||
|
|
||
| Currently, it wraps the Apache Iceberg sink. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| table: str, | ||
| catalog_name: Optional[str] = None, | ||
| catalog_properties: Optional[Mapping[str, str]] = None, | ||
| config_properties: Optional[Mapping[str, str]] = None, | ||
| partition_fields: Optional[Iterable[str]] = None, | ||
| table_properties: Optional[Mapping[str, str]] = None, | ||
| triggering_frequency_seconds: Optional[int] = None, | ||
| keep: Optional[Iterable[str]] = None, | ||
| drop: Optional[Iterable[str]] = None, | ||
| only: Optional[str] = None, | ||
| distribution_mode: Optional[str] = None, | ||
| autosharding: Optional[bool] = None, | ||
| ): | ||
| super().__init__() | ||
| self.table = table | ||
| self.catalog_name = catalog_name | ||
| self.catalog_properties = catalog_properties | ||
| self.config_properties = config_properties | ||
| self.partition_fields = partition_fields | ||
| self.table_properties = table_properties | ||
| self.triggering_frequency_seconds = triggering_frequency_seconds | ||
| self.keep = keep | ||
| self.drop = drop | ||
| self.only = only | ||
| self.distribution_mode = distribution_mode | ||
| self.autosharding = autosharding | ||
|
|
||
| def expand(self, pcoll): | ||
| """Expands the WriteToLakehouse transform.""" | ||
| return pcoll | write_to_iceberg( | ||
| table=self.table, | ||
| catalog_name=self.catalog_name, | ||
| catalog_properties=self.catalog_properties, | ||
| config_properties=self.config_properties, | ||
| partition_fields=self.partition_fields, | ||
| table_properties=self.table_properties, | ||
| triggering_frequency_seconds=self.triggering_frequency_seconds, | ||
| keep=self.keep, | ||
| drop=self.drop, | ||
| only=self.only, | ||
| distribution_mode=self.distribution_mode, | ||
| autosharding=self.autosharding, | ||
| ) | ||
95 changes: 95 additions & 0 deletions
95
python/src/test/python/job-builder-util-transforms/write_to_lakehouse_test.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,95 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import inspect | ||
| import unittest | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| from apache_beam.yaml.yaml_io import write_to_iceberg | ||
| from write_to_lakehouse import WriteToLakehouse | ||
|
|
||
|
|
||
| class WriteToLakehouseTest(unittest.TestCase): | ||
|
|
||
| def test_parameters_match_iceberg(self): | ||
| """Ensure that the set of parameters does not deviate from Iceberg.""" | ||
| lakehouse_params = inspect.signature(WriteToLakehouse).parameters | ||
| iceberg_params = inspect.signature(write_to_iceberg).parameters | ||
|
|
||
| self.assertEqual( | ||
| set(lakehouse_params.keys()), | ||
| set(iceberg_params.keys()), | ||
| "The set of parameters in WriteToLakehouse deviates from write_to_iceberg.", | ||
| ) | ||
| for name, param in iceberg_params.items(): | ||
| self.assertEqual( | ||
| lakehouse_params[name].default, | ||
| param.default, | ||
| f"Default value for parameter '{name}' deviates from write_to_iceberg.", | ||
| ) | ||
|
|
||
| @patch("write_to_lakehouse.write_to_iceberg") | ||
| def test_write_to_lakehouse(self, mock_write_to_iceberg): | ||
| mock_transform = MagicMock() | ||
| mock_write_to_iceberg.return_value = mock_transform | ||
|
|
||
| table = "lakehouse_catalog.dataset.table" | ||
| catalog_name = "lakehouse_catalog" | ||
| catalog_properties = {"type": "hadoop", "warehouse": "gs://bucket/warehouse"} | ||
| config_properties = {"fs.gs.impl": "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem"} | ||
| partition_fields = ["day(ts)", "category"] | ||
| table_properties = {"commit.retry.num-retries": "2"} | ||
| triggering_frequency_seconds = 60 | ||
| keep = ["field1", "field2"] | ||
| drop = ["field3"] | ||
| only = "field4" | ||
| distribution_mode = "hash" | ||
| autosharding = True | ||
|
|
||
| transform = WriteToLakehouse( | ||
| table=table, | ||
| catalog_name=catalog_name, | ||
| catalog_properties=catalog_properties, | ||
| config_properties=config_properties, | ||
| partition_fields=partition_fields, | ||
| table_properties=table_properties, | ||
| triggering_frequency_seconds=triggering_frequency_seconds, | ||
| keep=keep, | ||
| drop=drop, | ||
| only=only, | ||
| distribution_mode=distribution_mode, | ||
| autosharding=autosharding, | ||
| ) | ||
|
|
||
| pcoll = MagicMock() | ||
| transform.expand(pcoll) | ||
|
|
||
| mock_write_to_iceberg.assert_called_once_with( | ||
| table=table, | ||
| catalog_name=catalog_name, | ||
| catalog_properties=catalog_properties, | ||
| config_properties=config_properties, | ||
| partition_fields=partition_fields, | ||
| table_properties=table_properties, | ||
| triggering_frequency_seconds=triggering_frequency_seconds, | ||
| keep=keep, | ||
| drop=drop, | ||
| only=only, | ||
| distribution_mode=distribution_mode, | ||
| autosharding=autosharding, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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.