adiranjan25 opened a new pull request, #19205:
URL: https://github.com/apache/iceberg/pull/19205

   ## Summary
   
   Addresses #19194.
   
   This draft PR introduces regression coverage for a
   snapshot-isolation defect in Spark REPLACE TABLE AS SELECT
   (RTAS) when Write-Audit-Publish (WAP) is active.
   
   The current implementation can remove the main snapshot
   reference while staging replacement data or routing writes
   to an audit branch.
   
   ## Root cause
   
   - SparkCatalog.stageReplace creates a replacement transaction.
   - TableMetadata.buildReplacement removes the main reference.
   - Removing the main reference resets currentSnapshotId to -1.
   - SparkWrite stages the snapshot for WAP ID or routes the
     write to the configured WAP branch.
   - The replacement transaction commits without restoring
     the current main snapshot.
   
   ## Regression coverage
   
   Added two parameterized regression tests:
   
   - testRTASWithWapBranch
   - testRTASWithWapId
   
   The tests verify that the main snapshot exists before RTAS
   and remains intact afterward.
   
   ## Validation
   
   Environment:
   
   - Apache Iceberg upstream main
   - Baseline: f063ce667cb76cacecb28ea1836d691541e01c00
   - Spark 3.5
   - Scala 2.12
   - JDK 17
   
   Catalog configurations:
   
   - Hive SparkCatalog
   - Hadoop SparkCatalog
   - SparkSessionCatalog
   
   Results:
   
   - Compilation: successful
   - Regression tests executed: 6
   - Regression failures reproduced: 6
   
   All six tests reproduce the missing main snapshot.
   
   ## Proposed resolution
   
   One possible approach is to explicitly reject incompatible
   replacement operations under active WAP before committing
   replacement metadata.
   
   Fully isolated RTAS semantics may require broader design
   considerations because RTAS can modify table-wide schema,
   partition specifications, sort order, location and properties.
   
   ## Draft status
   
   This PR intentionally contains failing regression tests
   to demonstrate the existing defect.
   
   The production implementation is pending maintainer
   agreement on the intended replacement semantics.
   
   After agreement, I plan to implement the fix and extend
   validation across the applicable Spark versions.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to