spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conconscious <conconsci...@gmail.com>
Subject json in Cassandra to RDDs
Date Sat, 01 Jul 2017 10:54:00 GMT
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


Mime
View raw message