Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/19086#discussion_r136724918 --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala --- @@ -418,6 +436,39 @@ abstract class SessionCatalogSuite extends AnalysisTest { } } + test("rename global temp table") { + withBasicCatalog { catalog => + val globalTempTable = Range(1, 10, 2, 10) + catalog.createGlobalTempView("tbl1", globalTempTable, overrideIfExists = false) + assert(catalog.getGlobalTempView("tbl1") == Option(globalTempTable)) + assert(catalog.externalCatalog.listTables("db2").toSet == Set("tbl1", "tbl2")) + // If database is not specified, global temp table will not be renamed + catalog.setCurrentDatabase("db1") + intercept[AnalysisException] { + catalog.renameTable(TableIdentifier("tbl1"), TableIdentifier("tblone")) + } + catalog.setCurrentDatabase("db2") + catalog.renameTable(TableIdentifier("tbl1"), TableIdentifier("tblone")) + assert(catalog.getGlobalTempView("tbl1") == Option(globalTempTable)) + assert(catalog.externalCatalog.listTables("db2").toSet == Set("tblone", "tbl2")) + // Moving global temp table to another database is forbidden + intercept[AnalysisException] { + catalog.renameTable( + TableIdentifier("tbl1", Some("global_temp")), TableIdentifier("tbl3", Some("db2"))) + } + // Moving table from database to be a global temp table is forbidden + intercept[AnalysisException] { --- End diff -- Capture the error message and add an assert.
--- 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