2015-08-21 3:17 GMT-07:00 smagadi <sudhindramag...@fico.com>:

> teenagers .toJSON gives the json but it does not preserve the parent ids
>
> meaning if the input was {"name":"Yin",
> "address":{"city":"Columbus","state":"Ohio"},"age":20}
>
> val x= sqlContext.sql("SELECT name, address.city, address.state ,age FROM
> people where age>19 and age <=30 ").toJSON
>
>  x.collect().foreach(println)
>
> This returns back , missing address.
> {"name":"Yin","city":"Columbus","state":"Ohio","age":20}
> Is this a bug ?
>
>
You're not including it in the query, so of course it's not there.
Try


sqlContext.sql("Select * from ppl").toJSON.collect().foreach(println)

instead.
I get

{"address":{"city":"Columbus","state":"Ohio"},"name":"Yin"}

R.

Reply via email to