Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16514#discussion_r95112018
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala 
---
    @@ -555,6 +557,61 @@ class HiveDDLSuite
         }
       }
     
    +  test("Alter Table Set Location") {
    +    withTable("tab1", "tab2") {
    +      val catalog = spark.sessionState.catalog
    +      sql("CREATE TABLE tab1 using parquet AS SELECT 1 as a")
    +      sql("CREATE TABLE tab2 using parquet AS SELECT 2 as a")
    +      checkAnswer(spark.table("tab1"), Seq(Row(1)))
    +      checkAnswer(spark.table("tab2"), Seq(Row(2)))
    +      val metadataTab1 = catalog.getTableMetadata(TableIdentifier("tab1"))
    +      val locTab1 = metadataTab1.storage.locationUri
    +      val metadataTab2 = catalog.getTableMetadata(TableIdentifier("tab2"))
    +      val locTab2 = metadataTab2.storage.locationUri
    +      assert(locTab1.isDefined)
    +      assert(locTab2.isDefined)
    +      try {
    +        sql(s"ALTER TABLE tab2 SET LOCATION '${locTab1.get}'")
    +        checkAnswer(spark.table("tab2"), Seq(Row(1)))
    +      } finally {
    +        val root = new Path(locTab2.get)
    +        val fs = root.getFileSystem(spark.sparkContext.hadoopConfiguration)
    +        fs.delete(root, true)
    +      }
    +    }
    +  }
    +
    +  test("Alter Table Rename Partition") {
    --- End diff --
    
    Although we do not refresh the cache, we still can get the latest location 
of the table partition from the external catalog by calling 
[listPartitionsByFilter](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/CatalogFileIndex.scala#L69).
 We are not using the cached data for partition locations.
    
    Adding this test case is just to ensure we do not break this.


---
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

Reply via email to