How do I group data by a field in Spark?
<p>I want to read from a database two columns, group them by the first column and insert the result into another table using Spark. My program is written in Java. I tried the following:</p>

<pre><code>public static void aggregateSessionEvents(org.apache.spark.SparkContext sparkContext) {
    com.datastax.spark.connector.japi.rdd.CassandraJavaPairRDD&lt;String, String&gt; logs = javaFunctions(sparkContext)
            .cassandraTable("dove", "event_log", mapColumnTo(String.class), mapColumnTo(String.class))
            .select("session_id", "event");
    logs.groupByKey();
    com.datastax.spark.connector.japi.CassandraJavaUtil.javaFunctions(logs).writerBuilder("dove", "event_aggregation", null).saveToCassandra();
    sparkContext.stop();
}
</code></pre>

<p>This is giving me the error: </p>

<pre><code>The method cassandraTable(String, String, RowReaderFactory&lt;T&gt;) in the type SparkContextJavaFunctions is not applicable for the arguments (String, String, RowReaderFactory&lt;String&gt;, mapColumnTo(String.class))
</code></pre>

<p>My dependencies are:</p>

<pre><code>&lt;dependencies&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;2.0.1&lt;/version&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
    &lt;artifactId&gt;spark-streaming_2.10&lt;/artifactId&gt;
    &lt;version&gt;2.0.1&lt;/version&gt;
    &lt;scope&gt;provided&lt;/scope&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;1.6.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
</code></pre>

<p>How do I solve this?</p>