小编ara*_*nth的帖子

如何在spark 2.0中使用Cassandra Context

在之前的Spark版本1.6.1中,我正在使用spark Context创建Cassandra Context,

import org.apache.spark.{ Logging, SparkContext, SparkConf }
//config
val conf: org.apache.spark.SparkConf = new SparkConf(true)
.set("spark.cassandra.connection.host", CassandraHost)
.setAppName(getClass.getSimpleName)
 lazy val sc = new SparkContext(conf)
 val cassandraSqlCtx: org.apache.spark.sql.cassandra.CassandraSQLContext = new CassandraSQLContext(sc)
//Query using Cassandra context
  cassandraSqlCtx.sql("select id from table ")
Run Code Online (Sandbox Code Playgroud)

但在Spark 2.0中,Spark Context被Spark会话取代,我如何使用cassandra上下文?

cassandra apache-spark apache-spark-sql spark-cassandra-connector

1
推荐指数
1
解决办法
2430
查看次数