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

    https://github.com/apache/spark/pull/4492#discussion_r24471716
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala 
---
    @@ -127,7 +135,7 @@ private[sql] object JsonRDD extends Logging {
           StructType((topLevelFields ++ structFields).sortBy(_.name))
         }
     
    -    makeStruct(resolved.keySet.toSeq, Nil)
    +    nullTypeToStringType(makeStruct(resolved.keySet.toSeq, Nil))
    --- End diff --
    
    I think we should not apply `nullTypeToStringType` at here. Otherwise, we 
will not know if there is any `NullType` in the inferred schema. Keeping the 
`NullType` is pretty important when we want to union schemas in future. For 
example, the type of a field can be `NullType` in one dataset and can be 
`LongType` in another field. If we eagerly convert `NullType` to `StringType`. 
After union, we will have `StringType` instead of `LongType`.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to