[
https://issues.apache.org/jira/browse/SPARK-60455?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Yang Jie resolved SPARK-60455.
------------------------------
Resolution: Duplicate
Fixed by SPARK-60824 (b7557f1b5df on master, 4.4.0). ALTER TABLE ... ADD
CONSTRAINT ... CHECK whose condition folds to a constant, such as CHECK (true),
no longer fails with INTERNAL_ERROR.
> ALTER TABLE ADD CONSTRAINT CHECK fails with INTERNAL_ERROR when the condition
> folds to a constant
> -------------------------------------------------------------------------------------------------
>
> Key: SPARK-60455
> URL: https://issues.apache.org/jira/browse/SPARK-60455
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 5.0.0
> Reporter: Yang Jie
> Priority: Major
>
> ALTER TABLE ... ADD CONSTRAINT ... CHECK validates existing rows with the
> plan Filter(Not(cond), relation). When cond folds to a constant, the
> optimizer prunes the filter before V2 scan push-down, and the only planner
> strategy for AddCheckConstraint matches a DataSourceV2ScanRelation
> (DataSourceV2Strategy.scala:810), so planning fails:
> {noformat}
> ALTER TABLE t ADD CONSTRAINT c CHECK (current_date() > DATE'2023-01-01');
> -- [INTERNAL_ERROR] The Spark SQL phase planning failed with an internal
> error.
> ALTER TABLE t ADD CONSTRAINT c CHECK (1 > 0); -- the same
> {noformat}
> CREATE TABLE accepts these conditions. ALTER TABLE should accept them too, or
> reject them with a user-facing error.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]