Support Iceberg v3 write defaults in GPU writes [reduced-it] #17100
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #17100"
general
weight: 0.35
res-life
closes #15437
Description
Use Iceberg v3 write defaults when deciding whether a data write can run on the GPU. Scans check initial defaults. A position-only DELETE checks the delete schema, so an unrelated table-column default does not force CPU fallback.
Spark and the Iceberg catalog resolve an omitted column before writing. For example, on Spark 4.1.1 with Iceberg 1.11.0, both writers materialize
'current'when the INSERT omits the column and preserve an explicit NULL. When Spark rejects the omitted-column INSERT, the GPU matches the CPU error. The GPU writer copies defaults present in the actual write schema into the Parquet footer. A default stripped from that schema stays absent even when the table schema still declares it. Existing cuDF interfaces write the resolved columns and footer metadata. This change requires no native cuDF or JNI changes.<details>
<summary>Three parity checks and 13 scenarios</summary>
Compare independent CPU and GPU tables at three levels: SQL rows or errors, raw Parquet column values, and persisted default presence and value by field ID. The CPU footer uses
iceberg.schemaand the GPU footer uses Spark schema JSON. Read the files through Iceberg FileIO and PyArrow so an Iceberg reader cannot supply a missing physical value during the comparison.| # | Scenario | Expected result |
|---|---|---|
| 1 | Read a row written before adding the column | The reader returns the initial default
'legacy'; the column is absent on disk and the file hash stays unchanged. || 2 | INSERT omits the column | Match the CPU default or
CANNOT_FIND_DATA; a rejected write leaves existing files intact. || 3 | INSERT supplies an explicit string | Persist the supplied value. |
| 4 | INSERT supplies NULL | Persist NULL. |
| 5 | Change the write default between inserts | Where omission succeeds, persist
'current'then'next'in their respective generations. || 6 | Update the table default without DML | Preserve the initial default and all existing file hashes. |
| 7 | Matched MERGE updates a different column | Retain
'legacy'on the matched row. || 8 | Unmatched MERGE omits the column | Match the CPU insert value, including on the insert-only append path. |
| 9 | Matched MERGE explicitly sets the column to NULL | Persist NULL on the updated row. |
| 10 | The actual writer schema carries or omits defaults | Preserve field IDs, distinct supplied defaults and absent defaults. Unit tests also distinguish both instants in a daylight-saving overlap. |
| 11 | Append or MERGE encounters a write-only
fixed[2]default | Check CPU fallback separately for append, copy-on-write and merge-on-read. || 12 | Partial position DELETE on the same schema | Execute the GPU delta write and check the surviving row. |
| 13 | Standalone UPDATE in both write modes | Updating another column retains
'legacy'; assigning DEFAULT uses'current'where the catalog exposes it, while the other row retains'legacy'. Assert the GPU writer for each mode. |Scenarios 1–6 share one table history. A mixed MERGE covers 7–9 in both write modes. A separate insert-only MERGE exercises Spark’s append rewrite.
</details>
How this PR works
1. Write Parquet metadata
GpuSparkWrite.dataWriterSparkTypeFor()converts the actual write schema withGpuTypeToSparkTypeand the version-specificIcebergWriteDefaultAccessor. For each field,WriteDefaultAccessor.withWriteDefault()copies the initial default throughwithExistenceDefaultValue()and the write default throughwithCurrentDefaultValue(), when present. The values become SQL literals in SparkStructFieldmetadata; timestamp-with-zone literals preserve the instant across daylight-saving overlaps. Defaults absent from the write schema remain absent, even if the table schema declares them.The existing
GpuParquetWriter.tableWriterobtains Spark schema JSON metadata fromParquetWriteSupport.init(conf), passes it toParquetWriterOptions.withMetadata(), and creates the writer withTable.writeParquetChunked(). These existing cuDF interfaces persist the footer metadata without native cuDF or JNI changes.2. Write the materialized column
For the omitted-column INSERT path verified with Spark 4.1.1 and Iceberg 1.11.0, Iceberg's
TypeToSparkType.struct()exposes the table's write default in Spark's current-default metadata. Spark'sAnalyzer.ResolveOutputRelationthen callsTableOutputResolver.resolveOutputColumns()with default-value support enabled. WhenreorderColumnsByName()finds an omitted column,ResolveDefaultColumns.getDefaultValueExprOrNullLit()resolves its default expression, and the analyzer inserts aProject. For example, omittingstatuswith write default'current'produces the equivalent ofSELECT id, 'current' AS status FROM input.The projection generates the physical column during execution, before the batch reaches the Parquet writer. If the projection runs on the GPU,
GpuLiteral.columnarEval()expands the literal to a column with the batch's row count throughGpuExpressionsUtils.resolveColumnVector()andGpuColumnVector.from(scalar, numRows). The existing writer writes that column like any other input column. An explicit NULL already matches the target column and is preserved. If Spark cannot resolve the omitted column, analysis fails (for example, withCANNOT_FIND_DATA) and GPU execution preserves that behavior. This PR adds default-aware GPU eligibility checks and footer preservation; column materialization uses the existing Spark/RAPIDS execution path.Write performance
Measured GPU Iceberg v3 appends on one NVIDIA L4 with Spark 4.1.1, Iceberg 1.11.0, Java 17, a local Hadoop catalog and Snappy. Each append committed 262,144 rows with 16 columns to four Parquet files. The comparison used the upstream
97f4924dewriter and the PR writer (production sources identical ate064dd79eandf1f6d87cc), with the same native libraries.| Actual writer schema | Main append, ms | PR append, ms | Driver schema conversion, µs (main → PR) | Footer bytes/file (main → PR) |
|---|---:|---:|---:|---:|
| No defaults | 330.1 [321.2–343.2] | 325.0 [316.9–347.3] | 4.03 → 3.74 | 2,851 → 2,851 |
| Four string fields with initial and write defaults | 326.8 [318.8–341.1] | 329.7 [317.5–340.2] | 4.02 → 6.59 | 2,851 → 3,063 |
With four default pairs, median driver conversion increased by 2.56 µs and each footer grew by 212 bytes. Median append latency increased by 2.9 ms (+0.9%). The middle 50% of timings overlapped, and the paired JVM runs varied in both directions.
Append times are medians [IQR] including planning and the Iceberg commit. Four adjacent main/PR pairs alternated which version ran first. Each Spark JVM warmed up with four appends per schema, then timed six per schema (24 measurements per cell). The driver conversion was timed separately in warmed JVMs. Iceberg 1.11.0 strips defaults during ordinary SQL write-schema conversion, so the second workload used a benchmark catalog to pass four default pairs to the production writer. Both versions used the same fixture. We checked the GPU append plans and every file’s physical footer.
Validation
ICEBERG_EXTRA_CLASSPATH, using six workers. MERGE parameters now assert their exact GPU writers, omitted-column INSERT outcomes are compared independently, and hash-only checks avoid Parquet decoding.GpuSparkWriteSuitepassed, including the real GPU Parquet writer regression for distinct supplied defaults and field IDs. The final run compiled the suite with Scala 2.13.18 and used the repository's process-isolated runner against reactor-built dependencies and matching bundled JNI libraries.ICEBERG_EXTRA_CLASSPATH. Lakekeeper 0.13.9 with Iceberg 1.11.0 passed all 10 cases on each of Spark 4.0.4 and 4.1.1, with zero skips.Codex assisted Chong Gao with implementation and validation.
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance