spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ayan guha <guha.a...@gmail.com>
Subject Re: json in Cassandra to RDDs
Date Sat, 01 Jul 2017 13:54:51 GMT
Hi

If you are asking how to parse the json column from Cassandra, I would
suggest you to look into from_json function. It would help you to parse a
json field, given you know the schema upfront.

On Sat, Jul 1, 2017 at 8:54 PM, Conconscious <conconscious@gmail.com> wrote:

> Hi list,
>
> I'm using Cassandra with only 2 fields (id, json).
> I'm using Spark to query the json. Until now I can use a json file and
> query that file, but Cassandra and RDDs of the json field not yet.
>
> sc = spark.sparkContext
> path = "/home/me/red50k.json"
> redirectsDF = spark.read.json(path)
> redirectsDF.createOrReplaceTempView("red")
> result = spark.sql("select idv from red where idv = '9'")
> result.show()
>
> val conf = new SparkConf(true)
>     .set("spark.cassandra.connection.host", "192.168.1.74")
>     .set("spark.cassandra.auth.username", "cassandra")
>     .set("spark.cassandra.auth.password", "cassandra")
> val sc = new SparkContext("spark://192.168.1.74:7077", "test", conf)
> val table = sc.cassandraTable("test", "ttable")
> println(ttable.count)
>
> Some help please to join both things. Scala or Python code for me it's ok.
> Thanks in advance.
> Cheers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe e-mail: user-unsubscribe@spark.apache.org
>
>


-- 
Best Regards,
Ayan Guha

Mime
View raw message