spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenghao-intel <>
Subject [GitHub] spark pull request: [SPARK-4856] [SQL] NullType instead of StringT...
Date Wed, 17 Dec 2014 01:00:43 GMT
Github user chenghao-intel commented on a diff in the pull request:
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/json/JsonRDD.scala ---
    @@ -263,6 +263,8 @@ private[sql] object JsonRDD extends Logging {
             val elementType = typeOfArray(array)
             buildKeyPathForInnerStructs(array, elementType) :+ (key, elementType)
    +      // we couldn't tell what the type is if the value is null or empty string
    +      case (key: String, value) if value == "" || value == null => (key, NullType)
:: Nil
    --- End diff --
    I've updated the unit test, which probably make more sense.
    In some cases (as shown in the unit test), `""` is equivalent to `null` for struct type,
so we'd better not to say "it's MUST be `StringType` if we meet an empty string".
    In the meantime, the `NullType` is the `minimum` data type, and it can be promoted to
any other data type in `JsonRDD` (e.g. promote to StructType), however, it's impossible to
promote a `StringType` to `StructType`.
    It's safe to make it as `NullType` here, as we can promote it as `StringType` in the last
promote rules, see

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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message