review-comet-iceberg-write-pr
Use when reviewing a DataFusion Comet pull request that touches Iceberg writes, the split-operator write plan (IcebergWriteStrategy, IcebergWriteExec, IcebergCommitExec), the native Iceberg writer (CometIcebergWriteExec, iceberg_write.rs, iceberg_partition_path.rs), its eligibility gate (CometIcebergNativeWrite), or the iceberg-rust pin. Load alongside review-comet-pr.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 1.3k
- Forks
- 418
01 前言 Front Matter
- name
- review-comet-iceberg-write-pr
- description
- Use when reviewing a DataFusion Comet pull request that touches Iceberg writes, the split-operator write plan (IcebergWriteStrategy, IcebergWriteExec, IcebergCommitExec), the native Iceberg writer (CometIcebergWriteExec, iceberg_write.rs, iceberg_partition_path.rs), its eligibility gate (CometIcebergNativeWrite), or the iceberg-rust pin. Load alongside review-comet-pr.
- argument-hint
- <pr-number>
02 资源文件 1
- 参考文档README.md7.2 KB
03 SKILL.md 正文
<!-- 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-write-specific review for Comet PR #$ARGUMENTS.
REQUIRED BACKGROUND: Use review-comet-pr for PR metadata, existing comments, CI, the review
bar, and the output format. This skill only covers Iceberg writes.
Read the Contributor Guide First
| Doc | What you need from it |
|---|---|
docs/source/contributor-guide/iceberg-writes.md |
The two layers, the gate's properties, the wire format both ways, cleanup ownership |
docs/source/user-guide/latest/iceberg.md (Writes) |
The eligibility table and the accepted divergences from iceberg-java, as users see them |
docs/source/contributor-guide/iceberg-spark-tests.md |
What the Iceberg Spark test diffs enable, and what a green run does and does not prove |
The organizing rule is that the native writer produces what iceberg-java would have produced, or declines at plan time. Review every change against it. Iceberg write bugs are quiet: a divergent data file or manifest entry commits successfully, and every later reader of the table, Comet or not, inherits it. There is no query that fails to tell you.
1. Which Layer
| Layer | Code |
|---|---|
| Split-operator plan | IcebergWriteStrategy, IcebergWriteLogical, IcebergWriteExec, IcebergCommitExec, the spark-*/.../iceberg/ shims |
| Native writer | CometIcebergNativeWrite (gate and serde), IcebergWriteProtoTranslation, CometIcebergWriteExec, iceberg_write.rs |
| Shared with the scan | iceberg_common.rs (load_file_io, storage_factory_for, scheme_of), IcebergReflection, NativeConfig S3 translation |
spark.comet.write.iceberg.enabled switches both write layers. It is off by default, but once a
user turns it on, a change to the split plan affects every append, overwrite and copy-on-write
Iceberg write, including writes that never reach the native writer, and a change to the native
writer affects every eligible one. The testing-only
spark.comet.write.iceberg.splitOperator.enabled plans the split operator with the native writer
off. A change to a shared file affects the native Iceberg scan too.
2. Direction of the Gate Change
Establish first whether the PR widens or narrows what CometIcebergNativeWrite.getSupportLevel
admits. The two need different evidence.
- Narrowing (a new rule, a smaller allow list) costs performance only. Check that the rule
reports a specific reason and has a
CometIcebergWriteDetectionSuitecase. - Widening (lifting a rule, vetting a new property, a new scheme or type) means Comet now claims writes it previously refused. "The tests pass" is not evidence here, because the existing tests were written against the narrower gate. Ask for a test that writes the newly admitted configuration through both writers and compares the result, and for the user guide's eligibility table to change in the same PR.
For every gate change:
- [ ] It stays an allow list. New support is added by vetting a key or value, not by widening a
prefix or turning a deny list around. Unknown keys in
write.parquet.*,parquet.*, the session Hadoopparquet.*keys, and any other namespace that reaches the writer must still decline. - [ ] It reads the effective configuration (
TriggerContext.properties, table properties overlaid withSparkWrite.writeProperties), not the table properties alone. - [ ] It fails closed. A reflection lookup that cannot answer returns a reason. Look for
getOrElse(None)-shaped code, or acatchthat returnsNone, in a new rule. - [ ] It agrees with the native side. If the gate and the native code both interpret the same
input (a location's scheme, a partition spec, a type, a property value), check that they
interpret it identically on the edge cases: case,
scheme:/pathversusscheme://path, whitespace,voidpartition fields, missing source columns. A gate more permissive than the native code turns a fallback into a failed query (#6140). - [ ] Settings the native writer cannot honour decline. A table,
FileIOor Hadoop setting that iceberg-java would apply and the native writer ignores produces a successful write that silently differs: credentials, encryption, ACLs, tags, storage class (#6139). Thegs://path is the model (#5637). - [ ] New executor-side reflection is probed on the driver. Any iceberg-java member the task
closure or
IcebergReflection's commit-message assembly now calls must be added to whatrequireExecutorReflectionResolvableresolves, so a missing member is a plan-time fallback.
3. Output Parity with iceberg-java
For a change to the native writer, the metadata rebuild, or the pin, ask what iceberg-java writes for the same input, and check it at the pinned Iceberg versions (1.5.2, 1.8.1, 1.10.0, 1.11.0), not only the latest.
- [ ] Logical content and manifest metadata match: rows, partition values, record counts, metrics, spec id, sort order id. A difference here is a bug or a gate rule, never a new documented divergence.
- [ ] Physical differences are justified. A new file-level difference (encoding, footer metadata, roll points, file names) is added to the user guide's accepted-divergences list with the reason no reader can observe it.
- [ ] Metrics stay iceberg-java's.
rebuildDataFilesWithJavaMetricsre-derives manifest metrics from each file's footer withParquetUtil.footerMetricsandMetricsConfig. A PR that starts trusting iceberg-rust's metrics, or adds a native-tracked value beyond float and double NaN counts and bounds, needs a strong reason. - [ ] Value semantics match, not only formats. iceberg-rust compares and hashes partition values
with its own rules: until apache/iceberg-rust#3327 its
OrderedFloatequality treated-0.0and0.0as equal where Java'sFloat.comparedoes not (#6138). Check equality, hashing, ordering and rendering for float, double, timestamp, timestamptz, binary and decimal. - [ ] Timestamp partition values are UTC. Iceberg's
years,months,daysandhoursignore the session timezone. For date and timestamp sources,PartitionValueCalculator(iceberg_partition_value.rs) computes them with the same kernels iniceberg_funcs/temporal.rsthat key the sort in front of a clustered write, and those follow iceberg-java'sDateTimeUtil, including its pre-1970 rounding. A change that moves one of these transforms back to iceberg-rust, or that makes the kernels read the column's timezone label, breaks that agreement. iceberg-rust'syearsandmonthsfollow the label (apache/iceberg-rust#3142). Ask for a test in a non-UTC session for a change here. "Partition values" in the Writes section of the user-guideiceberg.mdlists where iceberg-rust differs, andtimezones.mdcovers how Comet labels timestamps. - [ ] Partition paths use the Java renderers. Directory names come from
CometLocationGenerator/partition_to_pathiniceberg_partition_path.rs, which follow iceberg-java'spartitionToPath, withjava_float_stringfor floats. A PR that calls iceberg-rust'sPartitionKey::to_pathorformat!on a value reintroduces a fixed bug. - [ ] Nothing nondeterministic reaches the output. Map iteration order leaks into file names,
manifest order and the row order of unordered reads. The fanout arm sorts its
DataFiles by path for this reason (#5776). - [ ] Casts stay strict.
decorate_batch_with_field_idscasts withsafe: false, so a type mismatch fails the task. A safe cast would write NULLs.
4. Failure Handling and Cleanup
Cleanup must never have an ownership gap. During the handoff, native remains armed until the JVM
has taken the locations and acknowledged that by polling EOF, so a brief overlap is intentional.
Read the ownership table in the contributor guide before reviewing any change near AbortOnDrop,
TrackingLocationGenerator, WrittenFileCleanup, drainNativePayload or
IcebergCommitExec.collectAndCommit.
- [ ] A new failure point between writing a file and the JVM taking the locations is covered by the native guard, including the path where the plan is dropped mid-write rather than returning an error.
- [ ] The locations column is still read, and ownership taken, before the manifest is decoded, so a decode failure still cleans up.
- [ ] Cleanup is best effort and never replaces the original exception (
addSuppressed, logging). - [ ] File names still carry the task attempt id, so a retried or speculative attempt cannot reuse another attempt's names.
- [ ] A job failure still aborts with the completed tasks' messages and deletes their files, and
the commit path still hands Iceberg genuine
SparkWrite$TaskCommitmessages, soSparkWrite.abortkeeps working. - [ ] The user-visible exception type is still what Spark's own write path throws on each Spark version (#6143).
- [ ] Every open file and every held-back row is reserved. Files must be opened through
MeteredParquetWriterBuilder, and rows the writer holds outside iceberg-rust (thePartitionFeeds, or anything a new feed holds back) must be added to whatrun_write_taskreserves. A builder that constructsParquetWriterBuilderdirectly leaves its files out of the task's memory reservation, so a wide fanout write grows past the pool instead of closing partitions early or failing its task. A fanout file must also report to its partition'sOpenFileMemory, or the partitions holding the most are not the ones closed. A storage scheme newly supported for writes needs its entry inStorageWrites::for_location: a file reports its flushed row groups until its storage has written them out, which a local file does at once and an object store only part by part.
5. Plan Shape
- [ ] AQE off as well as on. Transition and plan-shape changes must be tested with
spark.sql.adaptive.enabled=false. Per-stage transition insertion with AQE on has hidden a real bug (#5689), and Iceberg's own extension tests pick AQE at random per session, so an AQE-dependent bug shows up upstream as intermittent. - [ ] Transitions stay stripped the way they are.
CometIcebergWriteExecmust not become aColumnarToRowTransition, and the transition beneath it is removed in the separate pass inEliminateRedundantTransitions, before the maintransformUp. - [ ] Exactly one commit. The committer relies on
V2CommandExecmemoizingrun()and onIcebergWriteLogicalanchoring re-plans. A change here needs the AQE re-plan test to still pass. - [ ] Rules that rewrite plans keep the write node. Anything that restores Spark operators from
a Comet node's
originalPlanmust handle the write execs (#5719). - [ ] The kill switch still works. Code on the write path respects
spark.comet.enabled(#6142). - [ ] Credentials stay out of plan strings.
CometIcebergWriteExec.stringArgsmust not print the proto;catalog_propertiescarries translatedfs.s3a.*secrets.
6. The iceberg-rust Pin
native/Cargo.toml pins iceberg and iceberg-storage-opendal to a git revision.
- [ ] A pin bump is reviewed as a writer change: what changed upstream in the writers,
DataFile, manifests, partition handling and storage, and does the PR run the write suites and the Iceberg Spark tests? - [ ] Code that depends on iceberg-rust behaviour that is not an API, such as
clustered_write_errmatching the clustered writer's message text, still has the test that fails when upstream changes it. - [ ] Nothing starts depending on a personal fork. A PR that needs an unmerged iceberg-rust change says so and is not merged until the pin moves to an upstream revision.
7. Tests
| Suite | Covers |
|---|---|
CometIcebergWriteActionSuite |
Both layers end to end, parity with iceberg-java, DML, failure cleanup, AQE re-plans |
CometIcebergWriteDetectionSuite |
Most eligibility rules, accepted and declined |
CometIcebergSystemFunctionSuite |
Native partition transforms keeping partitioned writes native |
CometIcebergRewriteActionSuite |
rewrite_data_files through the split plan and the native writer |
IcebergWriteProtoTranslationSuite |
Property to IcebergParquetWriteSettings translation |
Rust tests in iceberg_write.rs |
Rolling, fanout order, clustered checks, cleanup guard, manifest round trip, memory reservation |
iceberg_partition_path.rs tests |
Partition path rendering against iceberg-java |
CometIcebergWriteBenchmark |
Native versus iceberg-java throughput |
CometIcebergEndToEndBenchmark |
Native read, shuffle and write against stock Spark, primitive and nested columns |
Ask specifically:
- [ ] Does the test prove the native writer ran? Every fallback is silent to the query. A test
that only compares results passes when both sides used iceberg-java. Look for
assertNativeWriteEngagesor a collectedCometIcebergWriteExec. - [ ] Is the input native?
withNativeEnabledalso setslocalTableScan; a test that setsspark.comet.write.iceberg.enabledby hand and insertsVALUESusually tests the JVM writer. - [ ] Is the comparison against iceberg-java (a sibling table written by the JVM writer) rather than hand-written expected values?
- [ ] Enough partitions for an ordering bug? Two partitions pass half the time; use eight or more.
- [ ] Does a failure test check storage state, the files under the data location against those the manifests reference, and not only the table contents?
- [ ] Does it run on each Iceberg version the behaviour depends on? Pull requests run only the
default Spark profile. Reflection, metrics conventions and path spelling differ across
Iceberg versions, so ask for the
run-iceberg-testslabel or a local run where they matter. - [ ] Is a green Iceberg Spark test run being cited as evidence? It does not show which writer
handled a test. The job summary counts writes per writer without naming tests (see "Which
writer ran each Iceberg write" in
contributor-guide/iceberg-spark-tests.md).
8. Do the PR Changes Make the Docs Stale?
contributor-guide/iceberg-writes.md: the component table and its paths, the gate properties, the proto description, the native adaptations list, the payload columns and the JVM steps after them, the cleanup ownership table, the test table, and the Iceberg version per Spark profileuser-guide/latest/iceberg.md, Writes section: the eligibility table, the "falls back" lists, the failure-handling section, and the accepted-divergences list. A PR that lifts or adds a rule, or changes a divergence, must update these. A divergence the code has since fixed must be removed.user-guide/latest/iceberg.md, Native Reader section: its unsupported-features list mentions writes. The Known Issues section lists the open write issuescontributor-guide/iceberg-spark-tests.md: the flags the diffs setCometConf.scaladoc strings for the two flags, when defaults or scope change
04 同仓库更多 Skills
wire-datafusion-function
Use when wiring an existing DataFusion or datafusion-spark function into Comet for a Spark expression. Identifies the right wiring pattern (one-line passthrough, datafusion-spark UDF registration, or custom serde with input massaging / restrictions), applies the Scala serde, registers the UDF in jni_api when needed, and adds SQL file tests. Assumes the function already exists upstream — if not, switch to `implement-comet-expression`.
suggest-native-expression
Use when picking the next Spark expression to implement natively in Comet, or when asked whether a specific codegen-dispatched expression is worth a native Rust implementation. Scores the candidate on how likely a native path can be 100% Spark-compatible and how much throughput or allocation it would save versus the JVM codegen dispatcher, records the verdict in the per-expression audit log so disqualified candidates are not re-litigated, and files a GitHub issue for the recommendation.
review-comet-shuffle-pr
Use when reviewing a DataFusion Comet pull request that touches native or JVM columnar shuffle, the shuffle writers and readers, partitioning, the Arrow IPC block format, shuffle compression, or the Celeborn integration. Load alongside review-comet-pr.
review-comet-pr
Use when reviewing a DataFusion Comet pull request. Covers the workflow that applies to every PR and routes to the area-specific review skills for expressions, FFI, memory management, shuffle, Iceberg writes, and documentation. Provides guidance to a human reviewer rather than posting comments.
review-comet-memory-pr
Use when reviewing a DataFusion Comet pull request that touches memory pools, memory reservations, spilling, the Spark TaskMemoryManager bridge, allocators, or memory-related configuration. Load alongside review-comet-pr.
review-comet-ffi-pr
Use when reviewing a DataFusion Comet pull request that crosses the JVM/native boundary, touching Arrow C Data or C Stream interface code, batch export and import, CometExecIterator, ScanExec, NativeUtil, CometVector subclasses, or jni_api. Load alongside review-comet-pr.