yyanyy opened a new pull request, #55590:
URL: https://github.com/apache/spark/pull/55590
### What changes were proposed in this pull request?
`BaseConstraint.toDescription()` now always emits `RELY|NORELY`, matching
`toDDL()` used by SHOW CREATE TABLE. Previously, `toDescription()` skipped the
`NORELY` token when `rely=false`, so the same constraint rendered differently
across the two surfaces.
After this change, the invariant holds:
`toDDL` is `"CONSTRAINT " + name + " " + toDescription`.
### Why are the changes needed?
After SPARK-52141 (DESCRIBE EXTENDED) and SPARK-52142 (SHOW CREATE TABLE)
landed, the two surfaces render the same constraint asymmetrically:
| State | DESCRIBE EXTENDED (before) | SHOW CREATE TABLE
|
|--------------|-----------------------------------|-------------------------------------|
| PK default | PRIMARY KEY (a) NOT ENFORCED | PRIMARY KEY (a) NOT
ENFORCED NORELY |
| CHECK default| CHECK (...) ENFORCED | CHECK (...) ENFORCED
NORELY |
The original review on PR #51577 considered skipping both `NOT ENFORCED` and
`NORELY` when default, but only `NORELY` was skipped because `ENFORCED`'s
default is per-subclass and not visible to `BaseConstraint`. The result is a
confusing experience: SHOW CREATE TABLE reports the rely state explicitly while
DESCRIBE EXTENDED hides it for the default value.
### Does this PR introduce any user-facing change?
Slight output change in DESCRIBE EXTENDED command output. DESCRIBE EXTENDED
now emits `NORELY` for constraints whose `rely` value is the default. PRIMARY
KEY / UNIQUE / FOREIGN KEY / CHECK constraints all show the full `ENFORCED|NOT
ENFORCED RELY|NORELY` suffix, matching SHOW CREATE TABLE.
### How was this patch tested?
Updated golden strings in the v2 `DescribeTableSuite` "desc table
constraints" test. Ran:
build/sbt 'sql/testOnly \
org.apache.spark.sql.execution.command.v2.DescribeTableSuite \
org.apache.spark.sql.execution.command.v2.ShowCreateTableSuite'
41 tests pass.
### Was this patch authored or co-authored using generative AI tooling?
No.
--
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]