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

    https://github.com/apache/spark/pull/16514#discussion_r95112371
  
    --- 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") {
    +    withTempView("tempView1") {
    +      withTable("partitionedTab") {
    +        spark.range(2).select('id as 'a, 'id as 
'b).createTempView("tempView1")
    +        sql(
    +          """
    +            |CREATE TABLE partitionedTab
    +            |USING parquet
    +            |PARTITIONED BY (b)
    +            |AS SELECT a, b from tempView1
    +          """.stripMargin)
    +        // fill the cache
    +        checkAnswer(spark.table("partitionedTab"), Seq(Row(0, 0), Row(1, 
1)))
    +
    +        sql("ALTER TABLE partitionedTab PARTITION (b=1) RENAME TO 
PARTITION (b=3)")
    +        checkAnswer(spark.table("partitionedTab"), Seq(Row(0, 0), Row(1, 
3)))
    +      }
    +    }
    +  }
    +
    +  test("Alter Table Rename Table") {
    --- End diff --
    
    The rename table command processing already called `refreshTable`. Thus, 
this is just to cover the test case.


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