title: Unable to fetch data from Cassandra using spark (java)
body: <p>I am new to Cassandra and Spark and trying to fetch data from DB using spark.
  I am using Java for this purpose.
  Problem is that there are no exceptions thrown or error occurred but still I am not able to get the data. Find my code below - </p>
  
  <pre><code>    SparkConf sparkConf = new SparkConf();
      sparkConf.setAppName("Spark-Cassandra Integration");
      sparkConf.setMaster("local[4]");
      sparkConf.set("spark.cassandra.connection.host", "stagingHost22");
      sparkConf.set("spark.cassandra.connection.port", "9042");
  
      sparkConf.set("spark.cassandra.connection.timeout_ms", "5000");
      sparkConf.set("spark.cassandra.read.timeout_ms", "200000");
  
  
      JavaSparkContext javaSparkContext = new JavaSparkContext(sparkConf);
      String keySpaceName = "testKeySpace";
      String tableName = "testTable";
  
      CassandraJavaRDD&lt;CassandraRow&gt; cassandraRDD = CassandraJavaUtil.javaFunctions(javaSparkContext).cassandraTable(keySpaceName, tableName);
  
      final ArrayList dataList = new ArrayList();
      JavaRDD&lt;String&gt; userRDD = cassandraRDD.map(new Function&lt;CassandraRow, String&gt;() {
  
          private static final long serialVersionUID = -165799649937652815L;
  
  
          public String call(CassandraRow row) throws Exception {
              System.out.println("Inside RDD call");
              dataList.add(row);
              return "test";
          }
      });
      System.out.println( "data Size -" + dataList.size());
  </code></pre>
  
  <p>Cassandra and spark maven dependencies are - </p>
  
  <pre><code>      &lt;dependency&gt;
          &lt;groupId&gt;com.datastax.cassandra&lt;/groupId&gt;
          &lt;artifactId&gt;cassandra-driver-core&lt;/artifactId&gt;
          &lt;version&gt;3.0.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.datastax.cassandra&lt;/groupId&gt;
          &lt;artifactId&gt;cassandra-driver-mapping&lt;/artifactId&gt;
          &lt;version&gt;3.0.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.datastax.cassandra&lt;/groupId&gt;
          &lt;artifactId&gt;cassandra-driver-extras&lt;/artifactId&gt;
          &lt;version&gt;3.0.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sparkjava&lt;/groupId&gt;
          &lt;artifactId&gt;spark-core&lt;/artifactId&gt;
          &lt;version&gt;2.5.4&lt;/version&gt;
      &lt;/dependency&gt;
       &lt;dependency&gt;
          &lt;groupId&gt;com.datastax.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-cassandra-connector_2.10&lt;/artifactId&gt;
          &lt;version&gt;2.0.0-M3&lt;/version&gt;
      &lt;/dependency&gt;
       &lt;dependency&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-core_2.10&lt;/artifactId&gt;
          &lt;version&gt;1.4.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-sql_2.10&lt;/artifactId&gt;
          &lt;version&gt;1.3.0&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>This is sure that stagingHost22 host has the cassandra data with keyspace - testKeySpace and table name - testTable. Find below query output - </p>
  
  <blockquote>
    <p>cqlsh:testKeySpace> select count(*) from testTable;</p>
    
    <h2>count</h2>
    
    <p>34</p>
    
    <p>(1 rows)</p>
  </blockquote>
  
  <p>Can Anybody please suggest what am I missing here?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Warm regards,</p>
  
  <p>Vibhav</p>