xushiyan commented on code in PR #5320: URL: https://github.com/apache/hudi/pull/5320#discussion_r966357792
########## hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestAlterTable.scala: ########## @@ -194,9 +194,14 @@ class TestAlterTable extends HoodieSparkSqlTestBase { val oldLocation = spark.sessionState.catalog.getTableMetadata(new TableIdentifier(tableName)).properties.get("path") spark.sql(s"alter table $tableName rename to $newTableName") val newLocation = spark.sessionState.catalog.getTableMetadata(new TableIdentifier(newTableName)).properties.get("path") - assertResult(false)( - newLocation.equals(oldLocation) - ) + if (HoodieSparkUtils.isSpark3_2) { Review Comment: @KnightChess spark 3.3 is supported. this also applies to 3.3 right? ########## hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestAlterTable.scala: ########## @@ -169,4 +168,77 @@ class TestAlterTable extends HoodieSparkSqlTestBase { } } } + + test("Test Alter Rename Table") { + withTempDir { tmp => + Seq("cow", "mor").foreach { tableType => + val tableName = generateTableName + // Create table + spark.sql( + s""" + |create table $tableName ( + | id int, + | name string, + | price double, + | ts long + |) using hudi + | tblproperties ( + | type = '$tableType', + | primaryKey = 'id', + | preCombineField = 'ts' + | ) + """.stripMargin) + + // alter table name. + val newTableName = s"${tableName}_1" + val oldLocation = spark.sessionState.catalog.getTableMetadata(new TableIdentifier(tableName)).properties.get("path") + spark.sql(s"alter table $tableName rename to $newTableName") + val newLocation = spark.sessionState.catalog.getTableMetadata(new TableIdentifier(newTableName)).properties.get("path") + if (HoodieSparkUtils.isSpark3_2) { + assertResult(false)( + newLocation.equals(oldLocation) + ) + } else { + assertResult(None) (oldLocation) + assertResult(None) (newLocation) + } + + + // Create table with location + val locTableName = s"${tableName}_loc" + val tablePath = s"${tmp.getCanonicalPath}/$locTableName" + spark.sql( + s""" + |create table $locTableName ( + | id int, + | name string, + | price double, + | ts long + |) using hudi + | location '$tablePath' + | tblproperties ( + | type = '$tableType', + | primaryKey = 'id', + | preCombineField = 'ts' + | ) + """.stripMargin) + + // alter table name. + val newLocTableName = s"${locTableName}_1" + val oldLocation2 = spark.sessionState.catalog.getTableMetadata(new TableIdentifier(locTableName)) + .properties.get("path") + spark.sql(s"alter table $locTableName rename to $newLocTableName") + val newLocation2 = spark.sessionState.catalog.getTableMetadata(new TableIdentifier(newLocTableName)) + .properties.get("path") + if (HoodieSparkUtils.isSpark3_2) { Review Comment: ditto -- 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: commits-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org