Hot questions for Using Cassandra in hadoop


The class org.apache.cassandra.hadoop.pig.CqlStorage is a pig Cassandra driver.

This class is present in following Cassandra versions,

  • 2.0.5 ( apache-cassandra-2.0.5.jar )
  • 2.1.12 ( apache-cassandra-2.1.12.jar )

But it is missing in following latest releases

  • 2.2.4 ( apache-cassandra-2.2.4.jar )
  • 3.0.0 ( apache-cassandra-3.0.0-alpha1.jar )

Not sure why it is discontinued and what is the alternative for the same.


Check out the JIRA about it here --

Nobody's currently responsible for Pig code. As a result, there is nobody to fix the issues, or even fix the failing tests (of which we unfortunately have plenty). Those tests take time to run, constantly hang, and fail with cryptic errors that we don't know how to fix and don't have enough resources to investigate. Thus I propose we deprecate Pig support in 2.2 and remove it in 3.0.


I'm fairly new to Cassandra. I'm using hadoop to bulk load data into a cassandra cluster using CqlOutputFormat. I'm unable to find sufficient examples in internet to tailor it to my usecase.

I'm specifically using it to insert data into the cluster using the statement ,

insert into pinseries (pin, timeseries) values(?, ?)

I'm not sure how the context.write() should look like to make this work. There seems to be enough examples to see how it should work for an update statement (The wordcount from examples will do). But can someone tell me how to use that in insert mode?


The CqlRecordWriter used by the CqlOutputFormat doesn't support insert statements only update statements so you will need to use update to insert your data. Along the lines of:

update pinseries set timeseries = ? where pin = ?

I'm assuming that pin is your primary key.


I want to load cassandra table to a datafram in spark, I have followed the sample programes below (found in this answer), but I am getting an execption mentioned below, I have tried to load the table to RDD first then convert it to Datafrme, loading the RDD is successful, but when I try to convert it to a dataframe I am getting the same execption faced in the first methdology, any suggestions ? I am using Spark 2.0.0, Cassandra 3.7, and Java 8.

 public class SparkCassandraDatasetApplication {
 public static void main(String[] args) {
 SparkSession spark = SparkSession
          .config("spark.sql.warehouse.dir", "/file:C:/temp")
          .config("", "")
          .config("spark.cassandra.connection.port", "9042")

 //Read data to dataframe
 // this is throwing an exception
 Dataset<Row> dataset ="org.apache.spark.sql.cassandra")
        .options(new HashMap<String, String>() {
                put("keyspace", "mykeyspace");
                put("table", "mytable");

   //Print data;       

When submitted I am getting this exception:

Exception in thread "main" java.util.ServiceConfigurationError: org.apache.hadoop.fs.FileSystem: Provider org.apache.hadoop.fs.s3.S3FileSystem not found
at java.util.ServiceLoader.access$300(
at java.util.ServiceLoader$LazyIterator.nextService(
at java.util.ServiceLoader$
at java.util.ServiceLoader$
at org.apache.hadoop.fs.FileSystem.loadFileSystems(
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(
at org.apache.hadoop.fs.FileSystem.createFileSystem(
at org.apache.hadoop.fs.FileSystem.access$200(
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(
at org.apache.hadoop.fs.FileSystem$Cache.get(
at org.apache.hadoop.fs.FileSystem.get(
at org.apache.hadoop.fs.Path.getFileSystem(
at org.apache.spark.sql.catalyst.catalog.SessionCatalog.makeQualifiedPath(SessionCatalog.scala:115)
at org.apache.spark.sql.catalyst.catalog.SessionCatalog.createDatabase(SessionCatalog.scala:145)

Using the RDD method to read from cassandra is successful ( i have tested it with count() call), but converting the RDD to DF is throwing the same exception faced in the first method.

public class SparkCassandraRDDApplication {
public static void main(String[] args) {
             SparkSession spark = SparkSession
              .config("spark.sql.warehouse.dir", "/file:/opt/spark/temp")
              .config("", "")
              .config("spark.cassandra.connection.port", "9042")

    SparkContext sc = spark.sparkContext();

    JavaRDD<UserData> resultsRDD = javaFunctions(sc).cassandraTable("mykeyspace", "mytable",CassandraJavaUtil.mapRowTo(UserData.class));

    //This is again throwing an exception
    Dataset<Row> usersDF = spark.createDataFrame(resultsRDD, UserData.class);

    resultsRDD.foreach(data -> {



Please check if "hadoop-common-2.2.0.jar" is available in classpath. You can test your application by creating a jar including all the dependencies. Use below pom.xml in which maven-shade-plugin is used to include all the dependencies to create uber jar.

<project xmlns="" xmlns:xsi=""

You can run the jar like below

spark-submit --class com.abaghel.examples.spark.cassandra.SparkCassandraDatasetApplication spark-cassandra-1.0.0-SNAPSHOT.jar


I am currently using Hadoop and Cassandra to run Map Reduce tasks.

It works fine, but I am wanting to allow the reduce output to begin inserting data to a Cassandra table with a Map column type.

I have tried just simply changes the value out type to Map in the Reducer but this begins to cause issues internally the cassandra.hadoop implementation as it is always requiring a List.

I have tried to change the OutputValueClass setting, but to no avail.

Has anyone else had luck with outputting something other than List or be able to point me in the direction to understand how it might be achievable.


I managed to figure out what I wanted to do, apologies for answering my own question just thought it may help people in a similar situation. Or will be able to tell me that my new way of thinking is also wrong.

I actually misunderstood what the KeyValueOut for a reducer was actually doing. My assumption was that I could change this value to be anything I wanted to write to Cassandra, and that the underlying Driver would just pick it up. For example Map or Text or Blob. However, I now think that it always has to be a List of ByteBuffers to allow anything to go into Cassandra from Hadoop.

I managed to get it working with the correct type by using the following:

     private ByteBuffer ExampleForMapTypes(JSONObject data){
        Map<String, String> mapper = new HashMap<>();            
        String user = data.get("Map_Left").toString();
        String agent = data.get("Map_Right").toString();
        mapper.put(user, agent);

        return MapType
          .getInstance(UTF8Type.instance, UTF8Type.instance)

The decompose method will return the ByteBuffer and this in turn allows the Cassandra driver to read what the output is going to be and properly handle it in the query. In this example it will output to a Cassandra Column of type Map


I'm a seasoned LAMP Developer and have decent experience with php, nginx, haproxy, redis, mongodb, and aws services. Whenever large data requirement comes to the table I go with aws web services and recently started reading about big data expecting to play with the technology on my own instead of using a hosted service for large data handling, stream processing etc.

However it's not the same journey like learning LAMP and because of the nature of the use cases it's hard to find good resources for a newbie. Specially for someone who haven't been with the Java eco system. (To my understanding Java software pretty much cover the popular big data stacks). The below list of softwares popups in pretty much everywhere when talking about big data, but it's very hard to grasp the concept of each and descriptions available at home pages of each project is pretty vague.

For instance "Cassandra", on surface it's the a good database to store time series data, but when reading more about analytics then other stacks come up, hadoop, pig, zookeeper etc.

  • Cassandra
  • Flink
  • Flume
  • Hadoop
  • Hbase
  • Hive
  • Kafka
  • Spark
  • Zookeeper

So in a nutshell, what does these software do? In context to big data, some of these projects share the same aspects, why do they co-exist then? what's the advantage? when to use what?


As for hadoop, you have to understand, that Hadoop can mean two things, depending on the context. A bit like the term "Linux", if your familiar with that.

  • only the core: The real "Hadoop" is only a file system for decentralized storage of very large files + request framework to these files via Map/Reduce.
  • the whole ecosystem: This includes the core and all other tools that have been put onto hadoop for data analytics. Flume, Hbase, Hive, Kafka, Spark, Zookeeper are terms belonging to this category. Flink also might be, I am not sure.

Cassandra might also belong to the second category, because "Hadoop integration was added way back in version 0.6 of Cassandra".

To understand the whole ecosystem better, you have to understand how this is all structured:

From bottom to top:

  • bottom layer: Here you have your distributed file system and the Map/Reduce request framework. HDFS is the name of the file system, you will also see this term a lot. On top of HDFS, you can use HBase, which is a column oriented database on top of HDFS ¹.
  • middle layer, execution engines: In the middle we have several different engines, which can query the hadoop file system for information. Actually, some people put Map/Reduce on a second layer, because the Hadoop environment now also includes Tez and Spark. Tez speeds up queries by using graphs for map/reduce execution, I think. And Spark is an in-memory engine.
  • top layer, user abstractions: On top of the execution engines you have the user API/abstractions. This includes apache Hive (SQL like queries) and Pig (in my eyes a mixture of SQL and programming language). But there are also more specialized abstractions like MLlib, which is a library for machine learning on top of a hadoop system using Spark as middle layer.

Somewhere aside, we also have management tools for this whole ecosystem. Managing servers, managing the task execution order (job scheduling) and so on. This is where Kafka and Zookeeper belong to.

¹ I currently do not understand the relationship between HBase vs. ORC files or Parquet.