Repository navigation
Add YAML tests for writing to Iceberg CDC sink #40542
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "comment": "Modify this file in a trivial way to cause this test suite to run", | ||
| "revision": 23 | ||
| "revision": 1 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also try these against Dataflow ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't seem to have Dataflow YAML tests set up. I ran the following on Dataflow though and got the expected output: DeltaLake to Iceberg: pipeline:
type: chain
transforms:
- type: ReadFromDeltaCDC
config:
table: "gs://ahmedabualsaud/delta/orders"
start_version: 0
end_version: 3
include_metadata_columns: ["_change_type", "_commit_version"]
hadoop_config:
"fs.gs.impl": "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem"
"fs.AbstractFileSystem.gs.impl": "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFS"
"fs.gs.auth.type": "APPLICATION_DEFAULT"
"fs.gs.project.id": "apache-beam-testing"
- type: WriteToIceberg
config:
table: "shop.orders_from_delta"
catalog_properties:
type: "hadoop"
warehouse: "gs://ahmedabualsaud/iceberg_cdc"
mode: "merge-on-read"
equality_columns: ["id"]
change_type_column: "_change_type"
change_type_map:
insert: "INSERT"
update_preimage: "UPDATE_BEFORE"
update_postimage: "UPDATE_AFTER"
delete: "DELETE"
sequence_number_column: "_commit_version"Iceberg to Iceberg: pipeline:
type: chain
transforms:
- type: ReadFromIcebergCDC
config:
table: "shop.orders_from_delta"
catalog_properties:
type: "hadoop"
warehouse: "gs://ahmedabualsaud/iceberg_cdc"
config_properties:
"fs.gs.impl": "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem"
"fs.AbstractFileSystem.gs.impl": "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFS"
"fs.gs.auth.type": "APPLICATION_DEFAULT"
"fs.gs.project.id": "apache-beam-testing"
include_metadata_columns: ["_change_type", "_commit_snapshot_sequence_number"]
- type: WriteToIceberg
config:
table: "shop.orders_from_iceberg"
catalog_properties:
type: "hadoop"
warehouse: "gs://ahmedabualsaud/iceberg_cdc"
mode: "merge-on-read"
equality_columns: ["id"]
change_type_column: "_change_type" |
||
| # (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. | ||
| # | ||
|
|
||
| fixtures: | ||
| - name: DELTA_TABLE | ||
| type: "apache_beam.yaml.integration_tests.temp_delta_cdc_table_with_updates" | ||
| - name: TEMP_DIR | ||
| type: "tempfile.TemporaryDirectory" | ||
|
|
||
| pipelines: | ||
| # Applies the Delta Lake table's changes in two batch syncs: version 0 (three | ||
| # new orders), then versions 1 to 3 (an update, a delete and a new order). The | ||
| # second sync changes rows that the first one committed. | ||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: ReadFromDeltaCDC | ||
| config: | ||
| table: "{DELTA_TABLE}" | ||
| start_version: 0 | ||
| end_version: 0 | ||
| include_metadata_columns: ["_change_type", "_commit_version"] | ||
| - type: WriteToIceberg | ||
| config: | ||
| table: "shop.orders" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| mode: "merge-on-read" | ||
| equality_columns: ["id"] | ||
| change_type_column: "_change_type" | ||
| change_type_map: | ||
| insert: "INSERT" | ||
| update_preimage: "UPDATE_BEFORE" | ||
| update_postimage: "UPDATE_AFTER" | ||
| delete: "DELETE" | ||
| sequence_number_column: "_commit_version" | ||
|
|
||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: ReadFromDeltaCDC | ||
| config: | ||
| table: "{DELTA_TABLE}" | ||
| start_version: 1 | ||
| include_metadata_columns: ["_change_type", "_commit_version"] | ||
| - type: WriteToIceberg | ||
| config: | ||
| table: "shop.orders" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| mode: "merge-on-read" | ||
| equality_columns: ["id"] | ||
| change_type_column: "_change_type" | ||
| change_type_map: | ||
| insert: "INSERT" | ||
| update_preimage: "UPDATE_BEFORE" | ||
| update_postimage: "UPDATE_AFTER" | ||
| delete: "DELETE" | ||
| sequence_number_column: "_commit_version" | ||
|
|
||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: ReadFromIceberg | ||
| config: | ||
| table: "shop.orders" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| - type: AssertEqual | ||
| config: | ||
| elements: | ||
| - {id: 1, item: "apple", qty: 4} | ||
| - {id: 3, item: "plum", qty: 2} | ||
| - {id: 4, item: "kiwi", qty: 1} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You 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. | ||
| # | ||
|
|
||
| fixtures: | ||
| - name: TEMP_DIR | ||
| type: "tempfile.TemporaryDirectory" | ||
|
|
||
| pipelines: | ||
| # Gives shop.orders two snapshots: three new orders, then an update, a delete | ||
| # and a new order. Each row carries its change type (op) and sequence number | ||
| # (seq). | ||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: Create | ||
| config: | ||
| elements: | ||
| - {id: 1, item: "apple", qty: 3, op: "INSERT", seq: 1} | ||
| - {id: 2, item: "pear", qty: 5, op: "INSERT", seq: 1} | ||
| - {id: 3, item: "plum", qty: 2, op: "INSERT", seq: 1} | ||
| - type: WriteToIceberg | ||
| config: | ||
| table: "shop.orders" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| mode: "merge-on-read" | ||
| equality_columns: ["id"] | ||
| change_type_column: "op" | ||
| sequence_number_column: "seq" | ||
|
|
||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: Create | ||
| config: | ||
| elements: | ||
| - {id: 1, item: "apple", qty: 3, op: "UPDATE_BEFORE", seq: 2} | ||
| - {id: 1, item: "apple", qty: 4, op: "UPDATE_AFTER", seq: 2} | ||
| - {id: 2, item: "pear", qty: 5, op: "DELETE", seq: 2} | ||
| - {id: 4, item: "kiwi", qty: 1, op: "INSERT", seq: 2} | ||
| - type: WriteToIceberg | ||
| config: | ||
| table: "shop.orders" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| mode: "merge-on-read" | ||
| equality_columns: ["id"] | ||
| change_type_column: "op" | ||
| sequence_number_column: "seq" | ||
|
|
||
| # Batch: replays every change in shop.orders into shop.orders_mirror. | ||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: ReadFromIcebergCDC | ||
| config: | ||
| table: "shop.orders" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| include_metadata_columns: | ||
| ["_change_type", "_commit_snapshot_sequence_number"] | ||
| - type: WriteToIceberg | ||
| config: | ||
| table: "shop.orders_mirror" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| mode: "merge-on-read" | ||
| equality_columns: ["id"] | ||
| change_type_column: "_change_type" | ||
|
|
||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: ReadFromIceberg | ||
| config: | ||
| table: "shop.orders_mirror" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| - type: AssertEqual | ||
| config: | ||
| elements: | ||
| - {id: 1, item: "apple", qty: 4} | ||
| - {id: 3, item: "plum", qty: 2} | ||
| - {id: 4, item: "kiwi", qty: 1} | ||
|
|
||
| # Streaming: replays the same changes into shop.orders_streaming_mirror. The | ||
| # far-future to_timestamp stops the stream at the latest snapshot. One-second | ||
| # commit windows put the two snapshots in separate commits, so the second | ||
| # commit updates and deletes rows that the first one wrote. | ||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: ReadFromIcebergCDC | ||
| config: | ||
| table: "shop.orders" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| streaming: true | ||
| starting_strategy: "earliest" | ||
| to_timestamp: 4102444800000 | ||
| include_metadata_columns: | ||
| ["_change_type", "_commit_snapshot_sequence_number"] | ||
| - type: WriteToIceberg | ||
| config: | ||
| table: "shop.orders_streaming_mirror" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| mode: "merge-on-read" | ||
| equality_columns: ["id"] | ||
| change_type_column: "_change_type" | ||
| triggering_frequency_seconds: 1 | ||
|
|
||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: ReadFromIceberg | ||
| config: | ||
| table: "shop.orders_streaming_mirror" | ||
| catalog_name: "hadoop_catalog" | ||
| catalog_properties: | ||
| type: "hadoop" | ||
| warehouse: "{TEMP_DIR}" | ||
| - type: AssertEqual | ||
| config: | ||
| elements: | ||
| - {id: 1, item: "apple", qty: 4} | ||
| - {id: 3, item: "plum", qty: 2} | ||
| - {id: 4, item: "kiwi", qty: 1} |
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.
Could you mention in the PR description why these were removed ? Won't this change the behavior for non-Dataflow runners ?
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. It would only change behavior for Flink, but we need it to run Python/YAML pipelines