Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.hanip-ss:spark-cassandra-connector:v1.6.0-1'
}
dependencies {
implementation("com.github.hanip-ss:spark-cassandra-connector:v1.6.0-1")
}
<dependency>
<groupId>com.github.hanip-ss</groupId>
<artifactId>spark-cassandra-connector</artifactId>
<version>v1.6.0-1</version>
</dependency>
libraryDependencies += "com.github.hanip-ss" % "spark-cassandra-connector" % "v1.6.0-1"
:dependencies [[com.github.hanip-ss/spark-cassandra-connector "v1.6.0-1"]]
This library lets you expose Cassandra tables as Spark RDDs, write Spark RDDs to Cassandra tables, and execute arbitrary CQL queries in your Spark applications.
saveToCassandra
calljoinWithCassandraTable
callrepartitionByCassandraReplica
callWHERE
clauseThe connector project has several branches, each of which map into different supported versions of Spark and Cassandra. For previous releases the branch is named "bX.Y" where X.Y is the major+minor version; for example the "b1.6" branch corresponds to the 1.6 release. The "master" branch will normally contain development for the next connector release in progress.
Refer to the compatibility table below which shows the major.minor version range supported between the connector, Apache Spark, Apache Cassandra, and the Cassandra Java driver:
| Connector | Spark | Cassandra | Cassandra Java Driver | | --------- | ------------- | --------- | --------------------- | | 2.0 | 2.0 | 2.1.5*, 2.2, 3.0 | 3.0 | | 1.6 | 1.6 | 2.1.5*, 2.2, 3.0 | 3.0 | | 1.5 | 1.5, 1.6 | 2.1.5*, 2.2, 3.0 | 3.0 | | 1.4 | 1.4 | 2.1.5* | 2.1 | | 1.3 | 1.3 | 2.1.5* | 2.1 | | 1.2 | 1.2 | 2.1, 2.0 | 2.1 | | 1.1 | 1.1, 1.0 | 2.1, 2.0 | 2.1 | | 1.0 | 1.0, 0.9 | 2.0 | 2.0 |
*Compatible with 2.1.X where X >= 5
API documentation for the Scala and Java interfaces are available online:
This project is available on Spark Packages; this is the easiest way to start using the connector: http://spark-packages.org/package/datastax/spark-cassandra-connector
This project has also been published to the Maven Central Repository. For SBT to download the connector binaries, sources and javadoc, put this in your project SBT config:
libraryDependencies += "com.datastax.spark" %% "spark-cassandra-connector" % "2.0.0-M3"
DataStax Academy provides free online training for Apache Cassandra and DataStax Enterprise. In DS320: Analytics with Spark, you will learn how to effectively and efficiently solve analytical problems with Apache Spark, Apache Cassandra, and DataStax Enterprise. You will learn about Spark API, Spark-Cassandra Connector, Spark SQL, Spark Streaming, and crucial performance optimization techniques.
New issues may be reported using JIRA. Please include all relevant details including versions of Spark, Spark Cassandra Connector, Cassandra and/or DSE. A minimal reproducible case with sample code is ideal.
Questions and requests for help may be submitted to the user mailing list.
#spark-cassandra-connector on irc.freenode.net. If you are new to IRC, you can use a web-based client.
To protect the community, all contributors are required to sign the DataStax Spark Cassandra Connector Contribution License Agreement. The process is completely electronic and should only take a few minutes.
To develop this project, we recommend using IntelliJ IDEA. Make sure you have installed and enabled the Scala Plugin. Open the project with IntelliJ IDEA and it will automatically create the project structure from the provided SBT configuration.
Tips for Developing the Spark Cassandra Connector
Checklist for contributing changes to the project:
To run unit and integration tests:
./sbt/sbt test
./sbt/sbt it:test
By default, integration tests start up a separate, single Cassandra instance and run Spark in local mode. It is possible to run integration tests with your own Cassandra and/or Spark cluster. First, prepare a jar with testing code:
./sbt/sbt test:package
Then copy the generated test jar to your Spark nodes and run:
export IT_TEST_CASSANDRA_HOST=<IP of one of the Cassandra nodes>
export IT_TEST_SPARK_MASTER=<Spark Master URL>
./sbt/sbt it:test
To generate the Reference Document use
./sbt/sbt spark-cassandra-connector-unshaded/run (outputLocation)
outputLocation defaults to doc/reference.md
Copyright 2014-2016, DataStax, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.