Skip to content

[SPARK-51834][SQL][FOLLOW-UP] Add missing .withConstraints() in AtomicReplaceTableExec#54322

Open
yyanyy wants to merge 1 commit intoapache:masterfrom
yyanyy:staging_catalog_constraint
Open

[SPARK-51834][SQL][FOLLOW-UP] Add missing .withConstraints() in AtomicReplaceTableExec#54322
yyanyy wants to merge 1 commit intoapache:masterfrom
yyanyy:staging_catalog_constraint

Conversation

@yyanyy
Copy link
Contributor

@yyanyy yyanyy commented Feb 14, 2026

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 noreply@anthropic.com

…omicReplaceTableExec`

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.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant