Fix Delta v1 writer detection for spark 4.0+ - #15927
Conversation
Signed-off-by: Jihoon Son <ghoonson@gmail.com>
88d82bd to
ab810ad
Compare
|
|
@greptile-apps I have updated the PR description to include why the performance evaluation is not required for this PR. Please have a look. |
| try: | ||
| with_gpu_session(lambda spark: replace_na_partition(spark, gpu_table), conf=confs) | ||
| plans = callback.getResultsWithTimeout(10000) | ||
| assert any(callback.contains(plan, "GpuAtomicReplaceTableAsSelectExec") |
There was a problem hiding this comment.
The regression test now checks only GpuAtomicReplaceTableAsSelectExec, the V2 replacement node, instead of also verifying GpuOverwriteByExpressionExecV1, the V1 path corrected by this PR. A regression in V1 writer detection could therefore pass while the surrounding V2 command still executes. The test also compares CPU and GPU results manually rather than using assert_gpu_and_cpu_are_equal_collect or assert_gpu_fallback_collect, as required by the repository's GPU integration-test directive. This requirement must be satisfied before merging; please retain an explicit V1-node assertion while using one of the required comparison helpers.
Rule Used: Integration tests must verify GPU execution using ... (source)
|
build |
…x-v1-writer-detect
21829e8
|
build |
| * Detect a DataFrameWriter V1 mode("overwrite").saveAsTable operation so it retains the | ||
| * existing table metadata. Delta versions before 4.1 require stack-trace inspection. | ||
| */ | ||
| def isV1WriterSaveAsTableOverwrite(options: DeltaOptions, mode: SaveMode): Boolean = { |
There was a problem hiding this comment.
Delta42xRuntimeShim extends DeltaRuntimeShimBase directly and does not override this method. That reintroduces the bug for Delta 4.2—its Spark 4.0 artifact checks classic.DataFrameWriter, while its Spark 4.1 artifact reads the explicit V1-overwrite option. Could Delta42xRuntimeShim delegate to CreateDeltaTableLikeShims just like Delta41xRuntimeShim?
Fixes #15926.
Description
A Delta
replaceWhereoverwrite throughDataFrameWriter.saveAsTablecould lose the existing partition specification when running on GPU with Spark 4.0 or later. When.partitionBy(...)was not restated, rows outside the replacement predicate survived, but their partition-column values were read asNULL.Spark 4.0 moved the classic writer implementation to
org.apache.spark.sql.classic.DataFrameWriter. The existing stack-trace-based V1 writer detection still checked the pre-Spark-4 class, causing the operation to be treated as a V2 table replacement and allowing the existing partition metadata to be replaced. This change should introduce no performance change as the fixed v1 writer detection for Spark 4.0 is identical as it for older versions except for the writer class name. For Spark 4.1, the detection logic should be even cheaper as it checks only theDeltaOptionsandSaveMode.This change moves V1
saveAsTableoverwrite detection behind the Delta runtime shim and uses the appropriate implementation for each supported Delta version:DataFrameWriter.CreateDeltaTableLikeShims.isV1WriterSaveAsTableOverwritehelper.The detected writer type is computed once and used consistently when updating table metadata, selecting replace semantics, and handling domain metadata.
The new integration test creates equivalent CPU and GPU partitioned Delta tables and performs a
replaceWhereoverwrite throughsaveAsTablewithout restating.partitionBy(...). It verifies that:GpuOverwriteByExpressionExecV1.region.The change has been verified locally against Spark 3.5.5, 4.0.1, and 4.1.1 by running the new test added.
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance