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

    https://github.com/apache/spark/pull/20963#discussion_r180610436
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
 ---
    @@ -2127,4 +2127,39 @@ class JsonSuite extends QueryTest with 
SharedSQLContext with TestJsonData {
           assert(df.schema === expectedSchema)
         }
       }
    +
    +  test("SPARK-23849: schema inferring touches less data if samplingRation 
< 1.0") {
    +    val predefinedSample = Set[Int](2, 8, 15, 27, 30, 34, 35, 37, 44, 46,
    +      57, 62, 68, 72)
    +    withTempPath { path =>
    +      val writer = Files.newBufferedWriter(Paths.get(path.getAbsolutePath),
    +        StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)
    +      for (i <- 0 until 100) {
    +        if (predefinedSample.contains(i)) {
    +          writer.write(s"""{"f1":${i.toString}}""" + "\n")
    +        } else {
    +          writer.write(s"""{"f1":${(i.toDouble + 0.1).toString}}""" + "\n")
    +        }
    +      }
    +      writer.close()
    +
    +      val ds = spark.read.option("samplingRatio", 
0.1).json(path.getCanonicalPath)
    --- End diff --
    
    ^ It's based upon actual experience before. There was a similar case that 
the test was broken due to the number of partitions and it took me a while to 
debug it, https://issues.apache.org/jira/browse/SPARK-13728


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to