lisancao opened a new pull request, #59386: URL: https://github.com/apache/spark/pull/59386
### What changes were proposed in this pull request? `CreateMetricViewCommand.createMetricViewInSessionCatalog` ignored the `replace` flag. When it's set and the view exists, this now does what `CreateViewCommand` does: reject a table (`EXPECT_VIEW_NOT_TABLE.NO_ALTERNATIVE`), check for cyclic references, uncache, drop, then create. ### Why are the changes needed? `CREATE OR REPLACE VIEW ... WITH METRICS` on an existing metric view in the session catalog fails with `TABLE_OR_VIEW_ALREADY_EXISTS` and keeps the old definition. Regular `CREATE OR REPLACE VIEW` works, and the v2 path (SPARK-54119) already handles it. ### Does this PR introduce _any_ user-facing change? Yes. `CREATE OR REPLACE VIEW ... WITH METRICS` replaces an existing metric view in the session catalog instead of failing. Affects 4.2.0. ### How was this patch tested? New tests in `MetricViewSuite`: replacing an existing metric view, and refusing to replace a table. The first fails on master without this change. `SimpleMetricViewSuite`, `MetricViewV2CatalogSuite` and `HiveMetricViewSuite` pass. This contribution is my original work, and I license it to the project under the project's open source license. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (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]
