Yan Yan created SPARK-56652:
-------------------------------

             Summary: DESCRIBE EXTENDED should always emit RELY/NORELY for 
constraints, matching SHOW CREATE TABLE
                 Key: SPARK-56652
                 URL: https://issues.apache.org/jira/browse/SPARK-56652
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 4.2.0
            Reporter: Yan Yan


After SPARK-52141 (DESCRIBE EXTENDED constraint output) and SPARK-52142
(SHOW CREATE TABLE constraint output) landed, the two surfaces render
the same constraint asymmetrically:

|| Constraint state || DESCRIBE EXTENDED || SHOW CREATE TABLE ||
| PRIMARY KEY (default) | {{PRIMARY KEY (a) NOT ENFORCED}} | {{PRIMARY KEY (a) 
NOT ENFORCED NORELY}} |
| PRIMARY KEY with RELY | {{PRIMARY KEY (a) NOT ENFORCED RELY}} | {{PRIMARY KEY 
(a) NOT ENFORCED RELY}} |
| CHECK (default) | {{CHECK (...) ENFORCED}} | {{CHECK (...) ENFORCED NORELY}} |

{{BaseConstraint.toDescription()}} (used by {{DescribeTableExec}})
skips the {{NORELY}} token when {{rely=false}}, while
{{BaseConstraint.toDDL()}} (used by {{ShowCreateTableExec}}) always
emits {{RELY|NORELY}}.

The original review on [PR
#51577|https://github.com/apache/spark/pull/51577#discussion_r2223415193]
suggested skipping both {{NOT ENFORCED}} and {{NORELY}} when at the
default value. The implementation only skipped {{NORELY}} (because
{{ENFORCED}}'s default is per-subclass and not visible to
{{BaseConstraint}}), leaving {{NOT ENFORCED}} always emitted. The
result is a confusing user experience where the rely state is hidden
in DESCRIBE EXTENDED but exposed in SHOW CREATE TABLE for the same
constraint.

This issue proposes making {{toDescription()}} always emit
{{RELY|NORELY}}, so both surfaces consistently render the full
enforcement and rely state. The natural invariant becomes:

{code:java}
toDDL  ==  "CONSTRAINT " + name + " " + toDescription
{code}

User-facing impact: DESCRIBE EXTENDED for default-rely constraints
will now print {{NORELY}} explicitly. Example before/after:

{code}
-- before
DESC EXTENDED tbl
...
# Constraints
pk_table_pk    PRIMARY KEY (id) NOT ENFORCED
uk_b           UNIQUE (b) NOT ENFORCED
c1             CHECK (c IS NOT NULL) ENFORCED
-- after
DESC EXTENDED tbl
...
# Constraints
pk_table_pk    PRIMARY KEY (id) NOT ENFORCED NORELY
uk_b           UNIQUE (b) NOT ENFORCED NORELY
c1             CHECK (c IS NOT NULL) ENFORCED NORELY
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to