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

    https://github.com/apache/spark/pull/3076#discussion_r19850345
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/InsertIntoHiveTableSuite.scala
 ---
    @@ -91,4 +98,44 @@ class InsertIntoHiveTableSuite extends QueryTest {
     
         sql("DROP TABLE hiveTableWithMapValue")
       }
    +
    +  test("SPARK-4203:random partition directory order") {
    +
    +    createTable[TestData]("tmp_table")
    +    val tmpDir = Files.createTempDirectory("hive_test")
    +
    +    sql(s"CREATE TABLE table_with_partition(c1 string) PARTITIONED by (p1 
string,p2 string,p3 string,p4 string,p5 string) location 
'${tmpDir.toUri.toString}'  ")
    +    sql("INSERT OVERWRITE TABLE table_with_partition  partition 
(p1='a',p2='b',p3='c',p4='c',p5='1') SELECT 'blarr' FROM tmp_table")
    +    sql("INSERT OVERWRITE TABLE table_with_partition  partition 
(p1='a',p2='b',p3='c',p4='c',p5='2') SELECT 'blarr' FROM tmp_table")
    +    sql("INSERT OVERWRITE TABLE table_with_partition  partition 
(p1='a',p2='b',p3='c',p4='c',p5='3') SELECT 'blarr' FROM tmp_table")
    +    sql("INSERT OVERWRITE TABLE table_with_partition  partition 
(p1='a',p2='b',p3='c',p4='c',p5='4') SELECT 'blarr' FROM tmp_table")
    +
    +    def listFolders(path: Path, acc: List[String]): List[List[String]] = {
    +      val dir = Files.newDirectoryStream(path)
    +      try {
    +        val folders = dir.filter(Files.isDirectory(_)).toList
    +        if (folders.isEmpty) {
    +          List(acc.reverse)
    +        } else {
    +          folders.flatMap(x => listFolders(x, x.getFileName.toString :: 
acc))
    +        }
    +      } finally {
    +        dir.close()
    +      }
    +    }
    +
    +    val expected = List(
    +      "p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=2"::Nil,
    +      "p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=3"::Nil ,
    +      "p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=1"::Nil ,
    +      "p1=a"::"p2=b"::"p3=c"::"p4=c"::"p5=4"::Nil
    +    )
    +
    +    assert(listFolders(tmpDir,List()).sortBy(_.toString()) == 
expected.sortBy(_.toString))
    +
    +    sql("DROP TABLE table_with_partition")
    +    sql("DROP TABLE tmp_table")
    +  }
    +
    +
    --- End diff --
    
    Remove these extra lines.


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