2

How do you get a basic Hello, world! example running in Spark with Cassandra? So far, we've found this helpful answer:

How to load Spark Cassandra Connector in the shell?

Which works perfectly!

Then we attempt to follow to documentation and the getting started example:

https://github.com/datastax/spark-cassandra-connector/blob/master/doc/1_connecting.md

It says to do this:

import com.datastax.spark.connector.cql.CassandraConnector

CassandraConnector(conf).withSessionDo { session =>
  session.execute("CREATE KEYSPACE test2 WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1 }")
  session.execute("CREATE TABLE test2.words (word text PRIMARY KEY, count int)")
}

But it says we don't have com.datastax.spark.connector.cql? Btw, we got the Spark connector from here:

Maven Central Repository (spark-cassandra-connector-java_2.11)

So how do you get to the point where you can create a keyspace, a table and insert rows after you have Spark and Cassandra running locally?

Community
  • 1
  • 1
AturSams
  • 7,568
  • 18
  • 64
  • 98

1 Answers1

2

The jar you downloaded only has the Java api so it won't work with the Scala Spark Shell. I recommend you follow the instructions on the Spark Cassandra Connector page.

https://github.com/datastax/spark-cassandra-connector/blob/master/doc/13_spark_shell.md

These instructions will have you build the full assembly jar with all the dependencies and add it to the Spark Shell classpath using --jars.

RussS
  • 16,476
  • 1
  • 34
  • 62