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

    https://github.com/apache/spark/pull/19492#discussion_r144754632
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonParser.scala
 ---
    @@ -35,19 +35,25 @@ import org.apache.spark.util.Utils
     /**
      * Constructs a parser for a given schema that translates a json string to 
an [[InternalRow]].
      */
    -class JacksonParser(
    -    schema: StructType,
    +private[sql] class JacksonParser(
    +    schema: DataType,
         val options: JSONOptions) extends Logging {
     
       import JacksonUtils._
       import com.fasterxml.jackson.core.JsonToken._
     
    +  def this(schema: StructType, options: JSONOptions) = this(schema: 
DataType, options)
    +  def this(schema: ArrayType, options: JSONOptions) = this(schema: 
DataType, options)
    +
       // A `ValueConverter` is responsible for converting a value from 
`JsonParser`
       // to a value in a field for `InternalRow`.
       private type ValueConverter = JsonParser => AnyRef
     
       // `ValueConverter`s for the root schema for all fields in the schema
    -  private val rootConverter = makeRootConverter(schema)
    +  private val rootConverter = schema match {
    +    case s: StructType => makeRootConverter(s)
    --- End diff --
    
    It is kind of easy to confused. Please add comment to each case like:
    ```scala
    private val rootConverter = schema match {
        case s: StructType => makeRootConverter(s) // For struct or array of 
struct.
        case a: ArrayType => makeRootConverter(a)  // For array of primitive 
types.
    }
    ```


---

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

Reply via email to