lisancao commented on code in PR #59386:
URL: https://github.com/apache/spark/pull/59386#discussion_r4253181110
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/command/metricViewCommands.scala:
##########
@@ -78,6 +79,18 @@ case class CreateMetricViewCommand(
// `where`) into the user-supplied properties so v1 DESCRIBE TABLE
EXTENDED surfaces the
// same descriptor rows as the v2 path in `DataSourceV2Strategy`.
val mergedProps = properties ++ metricView.getProperties
+ if (replace && catalog.tableExists(name)) {
+ // Handles `CREATE OR REPLACE VIEW ... WITH METRICS` on an existing
view, the same way
+ // `CreateViewCommand` does: nothing is retained from the old view, so
drop and recreate.
+ val existing = catalog.getTableMetadata(name)
+ if (!existing.isViewLike) {
+ throw
QueryCompilationErrors.unsupportedCreateOrReplaceViewOnTableError(
+ name.nameParts, replace)
+ }
+ ViewHelper.checkCyclicViewReference(analyzed, Seq(existing.fullIdent),
existing.fullIdent)
Review Comment:
Added the test. A metric view that references a metric view with the same
name now fails with `RECURSIVE_VIEW`. Before this, the replace went through and
left a view that reads itself, because `checkCyclicViewReference` only matched
`View`; I added the metric view nodes (`ResolvedMetricView`,
`MetricViewPlaceholder`) to it. The test also covers a cycle through a second
metric view.
--
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]