linhongliu-db commented on code in PR #59386:
URL: https://github.com/apache/spark/pull/59386#discussion_r4252436313
##########
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:
can you add a test to see what's the behavior for metric view refers a
metric view using the same name
--
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]