You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Yang Jie (Jira)" <ji...@apache.org> on 2026/10/22 08:22:00 UTC
[jira] [Created] (SPARK-60455) ALTER TABLE ADD CONSTRAINT CHECK fails with INTERNAL_ERROR when the condition folds to a constant
Yang Jie created SPARK-60455:
--------------------------------
Summary: 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
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: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org