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

    https://github.com/apache/spark/pull/16837#discussion_r100008693
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/PartitionProviderCompatibilitySuite.scala
 ---
    @@ -481,4 +484,30 @@ class PartitionProviderCompatibilitySuite
           assert(spark.sql("show partitions test").count() == 5)
         }
       }
    +
    +  test("SPARK-19359: renaming partition should not leave useless 
directories") {
    +    withTable("t", "t1") {
    +      Seq((1, 2, 3)).toDF("id", "A", "B").write.partitionBy("A", 
"B").saveAsTable("t")
    +      spark.sql("alter table t partition(A=2, B=3) rename to 
partition(A=4, B=5)")
    +
    +      var table = 
spark.sessionState.catalog.getTableMetadata(TableIdentifier("t"))
    +      var tablePath = new Path(table.location)
    +      val fs = tablePath.getFileSystem(spark.sessionState.newHadoopConf())
    +      // the `A=2` directory is still there, we follow this behavior from 
hive.
    +      assert(fs.listStatus(tablePath)
    +        
.filterNot(_.getPath.toString.contains("A=2")).count(_.isDirectory) == 1)
    +      assert(fs.listStatus(new Path(tablePath, 
"A=4")).count(_.isDirectory) == 1)
    +
    +
    +      Seq((1, 2, 3, 4)).toDF("id", "A", "b", "C").write.partitionBy("A", 
"b", "C").saveAsTable("t1")
    +      spark.sql("alter table t1 partition(A=2, b=3, C=4) rename to 
partition(A=4, b=5, C=6)")
    +      table = 
spark.sessionState.catalog.getTableMetadata(TableIdentifier("t1"))
    +      tablePath = new Path(table.location)
    +      // the `A=2` directory is still there, we follow this behavior from 
hive.
    +      assert(fs.listStatus(tablePath)
    +        
.filterNot(_.getPath.toString.contains("A=2")).count(_.isDirectory) == 1)
    --- End diff --
    
    If going to check `A=2` directory exist, I think here is `filter`?


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