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

    https://github.com/apache/spark/pull/21299#discussion_r187707287
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/json/JsonDataSource.scala
 ---
    @@ -99,12 +99,7 @@ object TextInputJsonDataSource extends JsonDataSource {
     
       def inferFromDataset(json: Dataset[String], parsedOptions: JSONOptions): 
StructType = {
         val sampled: Dataset[String] = JsonUtils.sample(json, parsedOptions)
    -    val rdd: RDD[InternalRow] = sampled.queryExecution.toRdd
    -    val rowParser = parsedOptions.encoding.map { enc =>
    -      CreateJacksonParser.internalRow(enc, _: JsonFactory, _: InternalRow)
    -    }.getOrElse(CreateJacksonParser.internalRow(_: JsonFactory, _: 
InternalRow))
    -
    -    JsonInferSchema.infer(rdd, parsedOptions, rowParser)
    +    JsonInferSchema.infer(sampled, parsedOptions, 
CreateJacksonParser.string)
    --- End diff --
    
    I reran the benchmarks on your branch. There is a difference in the schema 
inferring benchmarks
    ```
    JSON schema inferring:                   Best/Avg Time(ms)    Rate(M/s)   
Per Row(ns)   Relative
    
------------------------------------------------------------------------------------------------
    No encoding                                 46348 / 46679          2.2      
   463.5       1.0X
    UTF-8 is set                                45651 / 45731          2.2      
   456.5       1.0X
    ```
    before your changes:
    ```
    JSON schema inferring:               Best/Avg Time(ms)    Rate(M/s)   Per 
Row(ns)   Relative
    
--------------------------------------------------------------------------------------------
    No encoding                             38902 / 39282          2.6         
389.0       1.0X
    UTF-8 is set                            56959 / 57261          1.8         
569.6       0.7X
    ```
    As I wrote above _"array-based"_ parser is faster than _"string-based"_ but 
_"string-based"_ parser is faster than _"reader based"_ one.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to