import org.apache.spark.{SparkContext, SparkConf} import org.apache.spark.sql.{SQLContext, SchemaRDD} import org.apache.spark.sql.cassandra.CassandraSQLContext /** * Spark SQL Integration with the Spark Cassandra Connector * Uses Spark SQL simple query parser, so it has limit query supported. * Supports Selection, Writing and Join Queries. */ object SampleJoin extends App { val conf = new SparkConf(true) .set("spark.cassandra.connection.host", "127.0.0.1") .setMaster("local[*]) .setAppName("app") val sc = new SparkContext(conf) val cc = new CassandraSQLContext(sc) cc.setKeyspace("nosql_join") cc.sql(""" SELECT test1.a, test1.b, test1.c, test2.a FROM test1 AS test1 JOIN test2 AS test2 ON test1.a = test2.a AND test1.b = test2.b AND test1.c = test2.c """).map(Data(_)).saveToCassandra("nosql_join", "table3") sc.stop() }