File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
main/scala/org/apache/spark/sql/execution/command
test/scala/org/apache/spark/sql/execution/command Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -247,10 +247,12 @@ case class AlterTableRenameCommand(
247247 val catalog = sparkSession.sessionState.catalog
248248 // If this is a temp view, just rename the view.
249249 // Otherwise, if this is a real table, we also need to uncache and invalidate the table.
250- if (catalog.isTemporaryView(oldName) || catalog.isTemporaryTable(oldName) ) {
250+ if (catalog.isTemporaryView(oldName)) {
251251 catalog.renameTable(oldName, newName)
252252 } else {
253253 val table = catalog.getTableMetadata(oldName)
254+ DDLUtils .verifyOperationAllowableOnTempTable(catalog, table.identifier,
255+ " AlterTableRenameCommand" )
254256 DDLUtils .verifyAlterTableType(catalog, table, isView)
255257
256258 DDLUtils .ddlLockSafe(sparkSession.sessionState, " Alter Table Rename" , ! isView) {
Original file line number Diff line number Diff line change @@ -274,9 +274,10 @@ class TemporaryTableSuite extends QueryTest with SharedSparkSession {
274274 test(" test rename temporary table" ) {
275275 withTempTable(" t1" , " t2" ) {
276276 sql(" CREATE TEMPORARY TABLE t1 USING parquet AS SELECT 1" )
277- sql(" ALTER TABLE t1 RENAME TO t2" )
278- assert(spark.sessionState.catalog.getTempTable(" t1" ).isEmpty)
279- assert(spark.sessionState.catalog.getTempTable(" t2" ).nonEmpty)
277+ val e = intercept[AnalysisException ] {
278+ sql(" ALTER TABLE t1 RENAME TO t2" )
279+ }
280+ assert(e.message.contains(" Operation not allowed" ))
280281 }
281282 }
282283
@@ -415,7 +416,7 @@ class TemporaryTableSuite extends QueryTest with SharedSparkSession {
415416 }
416417 }
417418
418- test (" rename temporary table name should case insensitive" ) {
419+ ignore (" rename temporary table name should case insensitive" ) {
419420 withTempTable(" test_TMP" , " test_TMP2" ) {
420421 sql(" CREATE TEMPORARY TABLE test_TMP (id INT) USING PARQUET" )
421422 sql(" ALTER TABLE test_TMP rename to test_TMP2" )
You can’t perform that action at this time.
0 commit comments