LuciferYang opened a new pull request, #11267: URL: https://github.com/apache/paimon/pull/11267
### 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 own `PaimonReplaceTableStrategy`, which skipped that check. Paimon's catalogs do not declare the capability, so `CREATE TABLE t (id INT, CONSTRAINT positive CHECK (id > 0))` fails, but the same statement as `CREATE OR REPLACE TABLE` replaced an existing `t` and dropped the constraint. The strategy now calls Spark's `ResolveTableConstraints.validateCatalogForTableConstraint` before planning, through a new `SparkShim.validateTableConstraints`. The method does nothing by default, since Spark 3.x and 4.0 have no `TableSpec.constraints`. `paimon-spark4-common` overrides 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 with `AS 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) and `Spark42CompatibilityTest` each get a case where `CREATE OR REPLACE TABLE` with a `CHECK` constraint must fail with `UNSUPPORTED_FEATURE.TABLE_OPERATION` and leave the old row in place. -- 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]
