cloud-fan commented on code in PR #46267:
URL: https://github.com/apache/spark/pull/46267#discussion_r1595513707


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala:
##########
@@ -318,6 +329,51 @@ case class AlterViewAsCommand(
   }
 }
 
+/**
+ * Alter a view with given schema binding. If the view name contains database 
prefix, this command
+ * will alter a permanent view matching the given name, or throw an exception 
if view not exist.
+ * Else, this command will try to alter a temporary view first, if view not 
exist, try permanent
+ * view next, if still not exist, throw an exception.
+ *
+ * @param name the name of this view.
+ * @param viewSchemaMode The new schema binding mode.
+ */
+case class AlterViewSchemaBindingCommand(name: TableIdentifier, 
viewSchemaMode: ViewSchemaMode)
+  extends LeafRunnableCommand {
+
+  import ViewHelper._
+
+  override def run(session: SparkSession): Seq[Row] = {
+    val isTemporary = session.sessionState.catalog.isTempView(name)
+    if (isTemporary) {
+      throw QueryCompilationErrors.cannotAlterTempViewWithSchemaBindingError()
+    }
+    alterPermanentView(session, viewSchemaMode)
+    Seq.empty[Row]
+  }
+
+  private def alterPermanentView(session: SparkSession, viewSchemaMode: 
ViewSchemaMode): Unit = {
+    val viewMeta = session.sessionState.catalog.getTableMetadata(name)
+
+    // Detect cyclic view reference on ALTER VIEW.

Review Comment:
   we don't need to do this as the view query is not changed.



-- 
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]

Reply via email to