You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2017/08/24 04:10:21 UTC

[GitHub] spark pull request #19017: [SPARK-21804][SQL] json_tuple returns null values...

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

    https://github.com/apache/spark/pull/19017#discussion_r134923130
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala ---
    @@ -447,7 +448,18 @@ case class JsonTuple(children: Seq[Expression])
                   generator => copyCurrentStructure(generator, parser)
                 }
     
    -            row(idx) = UTF8String.fromBytes(output.toByteArray)
    +            val jsonValue = UTF8String.fromBytes(output.toByteArray)
    +            row(idx) = jsonValue
    +            idx = idx + 1
    +
    +            // SPARK-21804: json_tuple returns null values within repeated columns
    +            // except the first one; so that we need to check the remaining fields.
    +            while (idx < fieldNames.length) {
    +              if (fieldNames(idx) == jsonField) {
    +                row(idx) = jsonValue
    +              }
    +              idx = idx + 1
    +            }
    --- End diff --
    
    Could you rewrite it in short? More Scala?


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org