Repository navigation
[spark] Reject table constraints in column-list REPLACE TABLE on Spark 4.1+ - #11267
Open
LuciferYang wants to merge 1 commit into
Open
LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
Contributor
Author
|
cc @JingsongLi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
Since Spark 4.1, Spark's own REPLACE TABLE planning rejects table constraints when the catalog does not declare
SUPPORT_TABLE_CONSTRAINT. Paimon plans a column-list REPLACE TABLE with its ownPaimonReplaceTableStrategy, which skipped that check. Paimon's catalogs do not declare the capability, soCREATE TABLE t (id INT, CONSTRAINT positive CHECK (id > 0))fails, but the same statement asCREATE OR REPLACE TABLEreplaced an existingtand dropped the constraint.The strategy now calls Spark's
ResolveTableConstraints.validateCatalogForTableConstraintbefore planning, through a newSparkShim.validateTableConstraints. The method does nothing by default, since Spark 3.x and 4.0 have noTableSpec.constraints.paimon-spark4-commonoverrides it, which covers the 4.1 and 4.2 connectors. RTAS is left alone: Spark's own RTAS path has no such check, and since 4.1.2 the parser rejects constraints withAS SELECT.This came up in the review of #11246, which adds a Spark 4.3 connector on the same strategy.
Tests
DDLTestBase(run on Spark 4.1) andSpark42CompatibilityTesteach get a case whereCREATE OR REPLACE TABLEwith aCHECKconstraint must fail withUNSUPPORTED_FEATURE.TABLE_OPERATIONand leave the old row in place.