Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16386#discussion_r101684619
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/json/JsonFileFormat.scala
 ---
    @@ -37,29 +32,30 @@ import org.apache.spark.sql.types.StructType
     import org.apache.spark.util.SerializableConfiguration
     
     class JsonFileFormat extends TextBasedFileFormat with DataSourceRegister {
    +  override val shortName: String = "json"
     
    -  override def shortName(): String = "json"
    +  override def isSplitable(
    +      sparkSession: SparkSession,
    +      options: Map[String, String],
    +      path: Path): Boolean = {
    +    val parsedOptions = new JSONOptions(
    +      options,
    +      sparkSession.sessionState.conf.sessionLocalTimeZone,
    +      sparkSession.sessionState.conf.columnNameOfCorruptRecord)
    +    val jsonDataSource = JsonDataSource(parsedOptions)
    +    jsonDataSource.isSplitable && super.isSplitable(sparkSession, options, 
path)
    +  }
     
       override def inferSchema(
           sparkSession: SparkSession,
           options: Map[String, String],
           files: Seq[FileStatus]): Option[StructType] = {
    -    if (files.isEmpty) {
    -      None
    -    } else {
    -      val parsedOptions: JSONOptions =
    -        new JSONOptions(options, 
sparkSession.sessionState.conf.sessionLocalTimeZone)
    -      val columnNameOfCorruptRecord =
    -        parsedOptions.columnNameOfCorruptRecord
    -          
.getOrElse(sparkSession.sessionState.conf.columnNameOfCorruptRecord)
    -      val jsonSchema = JsonInferSchema.infer(
    -        createBaseRdd(sparkSession, files),
    -        columnNameOfCorruptRecord,
    -        parsedOptions)
    -      checkConstraints(jsonSchema)
    -
    -      Some(jsonSchema)
    -    }
    +    val parsedOptions = new JSONOptions(
    +      options,
    +      sparkSession.sessionState.conf.sessionLocalTimeZone,
    +      sparkSession.sessionState.conf.columnNameOfCorruptRecord)
    +    JsonDataSource(parsedOptions).infer(
    +      sparkSession, files, parsedOptions)
    --- End diff --
    
    we can merge it into the previous line


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