Preserve DSv2 metadata writes and reinserts for SPARK-50820 - #15474
Preserve DSv2 metadata writes and reinserts for SPARK-50820#15474firestarman wants to merge 2 commits into
Conversation
Route GPU ReplaceData and Delta write tasks through metadata-aware write/reinsert paths so Iceberg row-lineage columns match CPU Spark. Signed-off-by: Firestarman <firestarmanllc@gmail.com>
Exercise SPARK-50820 GPU metadata writes on format-version 3 tables by comparing CPU and GPU row-lineage columns after CoW UPDATE with CPU reads. Signed-off-by: Firestarman <firestarmanllc@gmail.com>
Greptile SummaryPreserve Spark 4 DSv2 metadata writes and Iceberg row lineage during copy-on-write and reinsert operations.
Confidence Score: 4/5The metadata-aware ReplaceData path needs OOM retry protection before merging because recoverable GPU memory pressure currently fails the write. The new task allocates projected and filtered GPU batches outside the repository’s retry framework, unlike the analogous delta-writing path, so a retryable RMM allocation failure aborts the operation. Files Needing Attention: sql-plugin/src/main/spark400/scala/org/apache/spark/sql/execution/datasources/v2/GpuReplaceDataExec.scala Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[ReplaceData batch] --> B{Operation}
B -->|WRITE| C[writer.write data]
B -->|WRITE_WITH_METADATA| D[Project metadata and data]
D --> E[writer.write metadata, data]
E --> F[GpuRowLineage.decorate]
F --> G[Iceberg data writer]
H[Delta write batch] --> I{INSERT or REINSERT}
I -->|INSERT| J[writer.insert]
I -->|REINSERT| K[writer.reinsert metadata, row]
K --> F
Reviews (1): Last reviewed commit: "Add Iceberg V3 row-lineage CoW UPDATE in..." | Re-trigger Greptile |
| withResource(rowProjection.project(batch)) { rows => | ||
| val dataBatch = GpuColumnVector.filter(rows, rowDataTypes, withMetadataFilter) | ||
| closeOnExcept(dataBatch) { _ => | ||
| if (dataBatch.numRows() > 0) { | ||
| val metadataBatch = withResource(metadataProjection.project(batch)) { metadata => | ||
| GpuColumnVector.filter(metadata, metadataDataTypes, withMetadataFilter) | ||
| } | ||
| GpuDsv2WriteMetadata.withMetadataSchema(metadataProj.schema) { | ||
| writer.write(metadataBatch, dataBatch) |
There was a problem hiding this comment.
Metadata writes bypass OOM retry
When a metadata-aware copy-on-write batch encounters a retryable GPU allocation failure during projection, filtering, or lineage decoration, this task performs the allocation outside withRetry or withRetryNoSplit, causing the write operation to abort instead of spilling and retrying.
Rule Used: GPU memory-allocating code must be wrapped in with... (source)
Fixes #15348.
Description
ReplaceDataExecthrough a metadata-aware writing task whenReplaceDataProjections.metadataProjectionis present, so CoW DSv2 writes callwriter.write(metadata, row)like Spark's SPARK-50820 CPU path.REINSERT_OPERATIONrows callDeltaWriter.reinsert(...)with metadata when available, instead of treating them as ordinary inserts.GpuDsv2WriteMetadataand IcebergGpuRowLineageso GPU Iceberg writers can decorate batches with_row_id/_last_updated_sequence_numberduring metadata writes and reinserts.GpuDsv2MetadataWriteSuiteand an Iceberg V3 CoW UPDATE integration test (test_iceberg_row_lineage_update_cow) that compares CPU/GPU user columns plus row-lineage metadata.Validation:
mvn -s /home/liangcail/.m2/settings_art.xml -f scala2.13/pom.xml -Dbuildver=400 -Dcuda.version=cuda13 -DskipTests validatemvn -s /home/liangcail/.m2/settings_art.xml -f scala2.13/pom.xml -Dbuildver=400 -Dcuda.version=cuda13 -pl tests test -DwildcardSuites=org.apache.spark.sql.execution.datasources.v2.GpuDsv2MetadataWriteSuitetest_iceberg_row_lineage_update_cowpassed with CPU Iceberg reads and GPU Iceberg writesNotes:
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance