[英]Compilation errors with spark cassandra connector and SBT
I'm trying to get the DataStax spark cassandra connector working. 我正在尝试让DataStax spark cassandra连接器正常工作。 I've created a new SBT project in IntelliJ, and added a single class.
我在IntelliJ中创建了一个新的SBT项目,并添加了一个类。 The class and my sbt file is given below.
类和我的SBT文件如下。 Creating spark contexts seem to work, however, the moment I uncomment the line where I try to create a cassandraTable, I get the following compilation error:
创建spark上下文似乎有效,但是,当我取消注释我尝试创建cassandraTable的那一行时,我得到以下编译错误:
Error:scalac: bad symbolic reference. 错误:scalac:错误的符号引用。 A signature in CassandraRow.class refers to term catalyst in package org.apache.spark.sql which is not available.
CassandraRow.class中的签名是指包org.apache.spark.sql中的术语催化剂,它不可用。 It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling CassandraRow.class.
它可能在当前类路径中完全丢失,或者类路径上的版本可能与编译CassandraRow.class时使用的版本不兼容。
Sbt is kind of new to me, and I would appreciate any help in understanding what this error means (and of course, how to resolve it). Sbt对我来说是一种新的东西,我很感激任何帮助,以了解这个错误的含义(当然,如何解决它)。
name := "cassySpark1"
version := "1.0"
scalaVersion := "2.10.4"
libraryDependencies += "org.apache.spark" % "spark-core_2.10" % "1.1.0"
libraryDependencies += "com.datastax.spark" % "spark-cassandra-connector" % "1.1.0" withSources() withJavadoc()
libraryDependencies += "com.datastax.spark" %% "spark-cassandra-connector-java" % "1.1.0-alpha2" withSources() withJavadoc()
resolvers += "Akka Repository" at "http://repo.akka.io/releases/"
And my class: 而我的班级:
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark。{SparkConf,SparkContext}
import com.datastax.spark.connector._
import com.datastax.spark.connector._
object HelloWorld { def main(args:Array[String]): Unit ={ System.setProperty("spark.cassandra.query.retry.count", "1")
object HelloWorld {def main(args:Array [String]):Unit = {System.setProperty(“spark.cassandra.query.retry.count”,“1”)
val conf = new SparkConf(true) .set("spark.cassandra.connection.host", "cassandra-hostname") .set("spark.cassandra.username", "cassandra") .set("spark.cassandra.password", "cassandra") val sc = new SparkContext("local", "testingCassy", conf)
> //val foo = sc.cassandraTable("keyspace name", "table name")
> // val foo = sc.cassandraTable(“keyspace name”,“table name”)
val rdd = sc.parallelize(1 to 100) val sum = rdd.reduce(_+_) println(sum) } }
您需要将spark-sql
添加到依赖项列表中
libraryDependencies += "org.apache.spark" %% "spark-sql" % "1.1.0"
Add library dependency in your project's pom.xml
file. 在项目的
pom.xml
文件中添加库依赖项。 It seems they have changed the Vector.class
dependencies location in the new refactoring. 看来他们在新的重构中改变了
Vector.class
依赖关系的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.