You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Barry Jones (JIRA)" <ji...@apache.org> on 2016/04/19 17:34:25 UTC

[jira] [Commented] (SPARK-14034) Converting to Dataset causes wrong order and values in nested array of documents

    [ https://issues.apache.org/jira/browse/SPARK-14034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15247988#comment-15247988 ] 

Barry Jones commented on SPARK-14034:
-------------------------------------

I have the same issue. Nested data values are associated with the wrong keys in the case class. From what I can tell the incorrect association seems consistent (I haven't noticed it shuffling arbitrarily upon reloads). I have tried creating a new file promoting the nested data to top-level data, and have confirmed it is correctly loaded when it isn't nested. So there appears to be a bug loading nested JSON as a Dataset.

> Converting to Dataset causes wrong order and values in nested array of documents
> --------------------------------------------------------------------------------
>
>                 Key: SPARK-14034
>                 URL: https://issues.apache.org/jira/browse/SPARK-14034
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.6.1
>            Reporter: Steven She
>
> I'm deserializing the following JSON document into a Dataset with Spark 1.6.1 in the console:
> {noformat}
> {"arr": [{"c": 1, "b": 2, "a": 3}]}
> {noformat}
> I have the following case classes:
> {noformat}
> case class X(arr: Seq[Y])
> case class Y(c: Int, b: Int, a: Int)
> {noformat}
> I run the following in the console to retrieve the value of `c` in the array, which should have a value of 1 in the data file, but I get the value 3 instead:
> {noformat}
> scala> sqlContext.read.json("../test.json").as[X].collect().head.arr.head.c
> res19: Int = 3
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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