TJX2014 commented on a change in pull request #28882:
URL: https://github.com/apache/spark/pull/28882#discussion_r447323119
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogSuite.scala
##########
@@ -218,4 +219,26 @@ class HiveExternalCatalogSuite extends
ExternalCatalogSuite {
val alteredTable = externalCatalog.getTable("db1", "parq_tbl")
assert(alteredTable.provider === Some("foo"))
}
+
+ test("SPARK-31751: serde property `path` overwrites hive table property
location") {
+ val catalog = newBasicCatalog()
+ val hiveTable = CatalogTable(
+ identifier = TableIdentifier("parq_alter", Some("db1")),
+ tableType = CatalogTableType.MANAGED,
+ storage = storageFormat,
+ schema = new StructType().add("col1", "int"),
+ provider = Some("parquet"))
+ catalog.createTable(hiveTable, ignoreIfExists = false)
+ val beforeAlterTable = externalCatalog.getTable("db1", "parq_alter")
+
assert(beforeAlterTable.storage.locationUri.toString.contains("parq_alter"))
+
+ externalCatalog.client.runSqlHive(
+ "alter table db1.parq_alter rename to db1.parq_alter2")
+
+ val e = intercept[AnalysisException](
+ externalCatalog.getTable("db1", "parq_alter2")
+ )
+ assert(e.getMessage.contains("not equal to table prop path")
+ && e.getMessage.contains("parq_alter2"))
+ }
Review comment:
We will get an exception when the path property is not consistent with
storage location.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]