-
Notifications
You must be signed in to change notification settings - Fork 343
feat: Optionally split the Iceberg V2 write operator into distinct writer and committer operations #4658
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
Open
jordepic
wants to merge
6
commits into
apache:main
Choose a base branch
from
jordepic:iceberg-writes-split-c1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,971
−4
Open
feat: Optionally split the Iceberg V2 write operator into distinct writer and committer operations #4658
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
359380e
docs: add Iceberg V2 writes user guide
135f164
feat: add split-operator plan for Iceberg V2 appends and overwrites
94a07bf
feat: extend Iceberg split plan to copy-on-write DELETE/UPDATE/MERGE
18a43e7
test: cover Iceberg V2 split-operator appends and overwrites
99ca922
test: cover Iceberg copy-on-write DELETE/UPDATE/MERGE writes
2078135
feat: enable Iceberg write split-operator plan by default
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| <!--- | ||
| 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. | ||
| --> | ||
|
|
||
| # Iceberg Writes: Comet's Split-Operator Plan (Experimental) | ||
|
|
||
| **This feature is experimental and enabled by default.** Set | ||
| `spark.comet.write.iceberg.splitOperator.enabled=false` to restore Spark's stock combined | ||
| write operator. | ||
|
|
||
| ## Overview | ||
|
|
||
| Spark writes an Iceberg table through a single physical operator that combines data-file | ||
| writing with metadata writing, committing, and catalog validation. Because that operator sits | ||
| outside Spark's Adaptive Query Execution (AQE), the sub-query feeding the write — the scans, | ||
| projects, sorts, and exchanges producing the rows — cannot be re-planned at runtime. | ||
|
|
||
| When `spark.comet.write.iceberg.splitOperator.enabled=true`, Comet rewrites eligible Iceberg | ||
| writes into two operators: | ||
|
|
||
| 1. **`IcebergWrite`** — writes the data files on the executors, exactly as iceberg-java does | ||
| today, and returns each task's serialized commit message. This operator and the sub-query | ||
| feeding it run inside AQE. | ||
| 2. **`IcebergCommit`** — collects the commit messages on the driver and performs the normal | ||
| Iceberg commit (including commit-time validation), outside AQE, exactly once. | ||
|
|
||
| Data files are still written by iceberg-java; only the plan shape changes. The split makes the | ||
| write's input visible to AQE and to Comet's columnar rules, and it is the groundwork for a | ||
| planned follow-up in which Comet writes the data files natively via | ||
| [iceberg-rust](https://github.com/apache/iceberg-rust). | ||
|
|
||
| ## Configuration | ||
|
|
||
| Standard Comet + Iceberg setup (see [`iceberg.md`](iceberg.md)) is all that is required; the | ||
| split-operator plan is applied automatically. To turn it off: | ||
|
|
||
| ``` | ||
| # Standard Comet / Iceberg wiring | ||
| spark.plugins=org.apache.spark.CometPlugin | ||
| spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions | ||
| spark.sql.catalog.<name>=org.apache.iceberg.spark.SparkCatalog | ||
| spark.sql.catalog.<name>.type=hadoop # or hive / glue / rest / ... | ||
| spark.sql.catalog.<name>.warehouse=... | ||
|
|
||
| # Split-operator plan (experimental, on by default); set to false to opt out | ||
| spark.comet.write.iceberg.splitOperator.enabled=false | ||
| ``` | ||
|
|
||
| ## Supported operations | ||
|
|
||
| The split-operator plan supports the following operations on every Spark version Comet | ||
| supports: | ||
|
|
||
| - `INSERT INTO` / DataFrame `append` (`AppendData`) | ||
| - `INSERT OVERWRITE`, static and dynamic (`OverwriteByExpression`, | ||
| `OverwritePartitionsDynamic`) | ||
| - Copy-on-write `DELETE` / `UPDATE` / `MERGE` (`ReplaceData`) | ||
|
|
||
| The mechanism behind row-level DML differs by Spark version: on Spark 4.0+ the analyzer emits | ||
| operation-coded rows that Comet's writer dispatches through `ReplaceData`'s projections, while | ||
| on Spark 3.4/3.5 the rewritten rows are written as a plain row stream. The supported set of | ||
| operations is the same either way. | ||
|
|
||
| On Spark 4.1+ the split plan matches two further stock-Spark behaviours: MERGE metrics are | ||
| forwarded to the writer's commit (Iceberg 1.11+ records them in the snapshot summary), and | ||
| cached catalog tables are recached by name after a write so cache entries survive schema | ||
| changes. | ||
|
|
||
| ## When Comet falls back to Spark's write operator | ||
|
|
||
| The rewrite is skipped — and the write runs through Spark's stock combined operator — when: | ||
|
|
||
| - `spark.comet.write.iceberg.splitOperator.enabled` is `false`; | ||
| - the write is not an Iceberg `SparkWrite` (any other V2 data source); | ||
| - the table uses merge-on-read: delta writes (Iceberg `WriteDelta`) are not intercepted; | ||
| - the write requires Spark's commit coordinator, which Comet's per-task commit protocol does | ||
| not use; | ||
| - Comet cannot reflect the Iceberg internals needed to build the two-operator plan (for | ||
| example an unrecognised write class or a `ReplaceData` projection it cannot map). | ||
|
|
||
| In every fallback case the write is planned as if Comet were absent; there is no correctness | ||
| trade-off, only no plan change. | ||
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
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.
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 we revisit the "identical coverage on every Spark version" claim? The copy-on-write ReplaceData path looks like it differs by version: 4.0+ uses operation-coded rows with projections, while 3.4/3.5 use a plain row stream. Would it be more accurate to state that the row-level DML mechanism differs by Spark version so the docs match the shim behavior?
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.
Reworded -- the docs now say the supported operations are the same on every version but the row-level DML mechanism differs (4.0+ operation-coded rows with projections, 3.4/3.5 a plain row stream).