yyanyy opened a new pull request, #54322:
URL: https://github.com/apache/spark/pull/54322

   
   ### What changes were proposed in this pull request?
   
   SPARK-51834 added `.withConstraints()` to `CreateTableExec` and 
`ReplaceTableExec` but missed `AtomicReplaceTableExec` in the same file. This 
causes `REPLACE TABLE` and `CREATE OR REPLACE TABLE` with constraints to 
silently drop them when the catalog implements `StagingTableCatalog`.
   
   Also fixes `StagingInMemoryTableCatalog` to forward constraints when 
constructing `InMemoryTable`, and adds regression tests for all four constraint 
types through the atomic replace path.
   
   
   ### Why are the changes needed?
   `AtomicReplaceTableExec` does not call `.withConstraints()` when building 
`TableInfo`, so `REPLACE TABLE` and `CREATE OR REPLACE TABLE` silently drop 
constraints when the catalog implements `StagingTableCatalog`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Previously, REPLACE TABLE and CREATE OR REPLACE TABLE with constraints 
would silently drop constraints when using a `StagingTableCatalog`. After this 
fix, constraints are correctly passed through to the catalog. 
   
   ### How was this patch tested?
   New unit tests in `UniqueConstraintSuite`, `PrimaryKeyConstraintSuite`, 
`CheckConstraintSuite`, and `ForeignKeyConstraintSuite` that exercise `REPLACE 
TABLE` with constraints through the atomic catalog path 
(`StagingInMemoryTableCatalog`). Verified that all 4 new tests fail without the 
fix and pass with it. All existing tests in these suites continue to pass.
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Claude Opus 4.6 <[email protected]>
   


-- 
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