Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/14746#discussion_r76597119 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/views.scala --- @@ -105,7 +96,14 @@ case class CreateViewCommand( } val sessionState = sparkSession.sessionState - if (isTemporary) { + // 1) CREATE VIEW: create a temp view when users explicitly specify the keyword TEMPORARY; + // otherwise, create a permanent view no matter whether the temporary view + // with the same name exists or not. + // 2) ALTER VIEW: alter the temporary view if the temp view exists; otherwise, try to alter + // the permanent view. Here, it follows the same resolution like DROP VIEW, + // since users are unable to specify the keyword TEMPORARY. + if (viewType == ViewType.Temporary || + (viewType != ViewType.Permanent && sessionState.catalog.isTemporaryTable(name))) { --- End diff -- This is not so readable, how about we use 3 branches for temp view and permanent view and any view individually? Also, we don't need to mention CREATE VIEW or ALTER VIEW here, the semantic is clearly defined by the SaveMode and ViewType, we just need to document how these codes match the semantic.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org