Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/14962#discussion_r77809642 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala --- @@ -159,12 +171,13 @@ case class AlterTableRenameCommand( override def run(sparkSession: SparkSession): Seq[Row] = { val catalog = sparkSession.sessionState.catalog DDLUtils.verifyAlterTableType(catalog, oldName, isView) - // If this is a temp view, just rename the view. - // Otherwise, if this is a real table, we also need to uncache and invalidate the table. - val isTemporary = catalog.isTemporaryTable(oldName) - if (isTemporary) { - catalog.renameTable(oldName, newName) - } else { + + // If the old table name contains database part, we should rename a metastore table directly, + // otherwise, try to rename a temp view first, if that not exists, rename a metastore table. + val renameMetastoreTable = + oldName.database.isDefined || !catalog.renameTempView(oldName.table, newName) --- End diff -- see https://github.com/apache/spark/pull/14962#discussion_r77808532 I'd like to avoid breaking existing behaviours here.
--- 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