Fix Spark 3.5.6 compatibility: Add truncate with overwrite support to StagedDeltaTableV2 #4919
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.
Which Delta project/connector is this regarding?
Description
Summary
Added support for TRUNCATE operations in Delta tables by:
SupportsTruncate
interface inDeltaV1WriteBuilder
SupportsTruncate
class from Spark SQL connector APIThis change enables proper handling of TRUNCATE TABLE operations on Delta tables.
Root Cause
Spark’s change apache/spark#50739 in 3.5.6 version
Spark 3.5.6 introduced stricter validation in the V2Writes rule (PR #50739) that requires tables to properly implement overwrite interfaces, not just declare capabilities.
The issue came from Delta tables not declaring TRUNCATE capability, leading to compatibility problems with Spark's enhanced validation system which became stricter with 3.5.6.
Fix
Updated StagedDeltaTableV2 class in DeltaCatalog.scala to properly support overwrite operations
Resolves #4671
How was this patch tested?
Tested locally by running scripts to Create and Replace Table
Does this PR introduce any user-facing changes?
No