You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Jean-Francois Gosselin <jf...@gmail.com> on 2017/02/10 06:12:29 UTC

From C* to DataFrames with JSON

Hi all,

I'm struggling (Spark / Scala newbie) to create a DataFrame from a C* table
but also create a DataFrame from column with json .

e.g. From C* table

| id | jsonData                      |
======================
| 1 |  {"a": "123", "b": "xyz" } |
+--+-------------------------------+
| 2 |  {"a": "3", "b": "bar" }     |


to Spark DataFrame:

| id |  a   |  b   |
===========
| 1 | 123 | xyz |
+--+------+-----+
| 2 | 3     | bar |


I'm using Spark 1.6 .

Thanks


JF

Re: From C* to DataFrames with JSON

Posted by Takeshi Yamamuro <li...@gmail.com>.
If you upgrade to v2.1, you can use to_json/from_json in sql.functions.

On Fri, Feb 10, 2017 at 3:12 PM, Jean-Francois Gosselin <
jfgosselin@gmail.com> wrote:

>
> Hi all,
>
> I'm struggling (Spark / Scala newbie) to create a DataFrame from a C*
> table but also create a DataFrame from column with json .
>
> e.g. From C* table
>
> | id | jsonData                      |
> ======================
> | 1 |  {"a": "123", "b": "xyz" } |
> +--+-------------------------------+
> | 2 |  {"a": "3", "b": "bar" }     |
>
>
> to Spark DataFrame:
>
> | id |  a   |  b   |
> ===========
> | 1 | 123 | xyz |
> +--+------+-----+
> | 2 | 3     | bar |
>
>
> I'm using Spark 1.6 .
>
> Thanks
>
>
> JF
>



-- 
---
Takeshi Yamamuro