dongjoon-hyun opened a new pull request, #60041: URL: https://github.com/apache/spark/pull/60041
### What changes were proposed in this pull request? This PR aims to fix `ALTER TABLE ... ADD CONSTRAINT ... CHECK` to fail with `TABLE_OR_VIEW_NOT_FOUND` instead of a raw `java.util.NoSuchElementException: None.get` when the target is a path, like ``parquet.`/some/path` ``. `ResolveSQLOnFile` now leaves the target of `AddCheckConstraint` unresolved, so `CheckAnalysis` reports it as a missing table. ### Why are the changes needed? Unlike the other constraint types, which use `UnresolvedTable`, a CHECK constraint reads its target through an `UnresolvedRelation` to validate the existing rows. `ResolveSQLOnFile` resolves it to a `LogicalRelation` without a catalog table, and `ResolveSessionCatalog` calls `catalogTable.get` on it. ```sql ALTER TABLE parquet.`/some/path` ADD CONSTRAINT c1 CHECK (id > 0); ``` **BEFORE** ``` java.util.NoSuchElementException: None.get ``` **AFTER** ``` [TABLE_OR_VIEW_NOT_FOUND] The table or view `parquet`.`/some/path` cannot be found. ... ``` The same statement with `UNIQUE (id)` or `PRIMARY KEY (id)` already fails with `TABLE_OR_VIEW_NOT_FOUND`, like the other `ALTER TABLE` commands on a path. ### Does this PR introduce _any_ user-facing change? Yes. The statement fails with `TABLE_OR_VIEW_NOT_FOUND` instead of `java.util.NoSuchElementException`. It failed before as well. For the same reason, a CHECK constraint on a missing path or on a non-file source, like ``jdbc.`/some/path` ``, now fails with `TABLE_OR_VIEW_NOT_FOUND` instead of `PATH_NOT_FOUND` or `UNSUPPORTED_DATASOURCE_FOR_DIRECT_QUERY`, as the other constraint types do. ### How was this patch tested? Pass the CIs with the newly added test case. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 -- 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]
