title: Spark Cassandra Table Filter in Spark Rdd
body: <p>I have to filter Cassandra table in spark, after getting data from a table via spark, apply filter function on the returned rdd ,we dont want to use where clause in cassandra api that can filter but that needs custom sasi index on the filter column, which has disk overhead issue due to multiple ss table scan in cassandra .
  for example:</p>
  <pre class="lang-scala prettyprint-override"><code>val ct = sc.cassandraTable(&quot;keyspace1&quot;, &quot;table1&quot;)
  val fltr = ct.filter(x=x.contains &quot;zz&quot;)
  </code></pre>
  <p>table1 fields are :</p>
  <ul>
  <li>dirid uuid</li>
  <li>filename text</li>
  <li>event int</li>
  <li>eventtimestamp bigint</li>
  <li>fileid int</li>
  <li>filetype int</li>
  </ul>
  <p>Basically we need to filter data based on filename with arbitrary string. since returned rdd is of type
  <code>com.datastax.spark.connector.rdd.CassandraTableScanRDD[com.datastax.spark.connector.CassandraRow] = CassandraTableScanRDD</code>
  and filter operations are restricted only to the methods of <code>CassandraRow</code> type which are <a href="https://i.stack.imgur.com/MGb5w.png" rel="nofollow noreferrer">enter image description here</a></p>
  <pre><code>    val ct = sc.cassandraTable(&quot;keyspace1&quot;, &quot;table1&quot;)
      scala&gt; ct
      res140: com.datastax.spark.connector.rdd.CassandraTableScanRDD[com.datastax.spark.connector.CassandraRow] = CassandraTableScanRDD[171] at RDD at CassandraRDD.scala:19
  </code></pre>
  <p>when i hit tab after &quot;x.&quot; in the below filter function, which shows the below methods of CassandraRow class`enter code here</p>
  <pre><code>scala&gt; ct.filter(x=&gt;x.
  columnValues   getBooleanOption   getDateTime         getFloatOption   getLongOption    getString             getUUIDOption     length
  contains       getByte            getDateTimeOption   getInet          getMap           getStringOption       getVarInt         metaData
  copy           getByteOption      getDecimal          getInetOption    getRaw           getTupleValue         getVarIntOption   nameOf
  dataAsString   getBytes           getDecimalOption    getInt           getRawCql        getTupleValueOption   hashCode          size
  equals         getBytesOption     getDouble           getIntOption     getSet           getUDTValue           indexOf           toMap
  get            getDate            getDoubleOption     getList          getShort         getUDTValueOption     isNullAt          toString
  getBoolean     getDateOption      getFloat            getLong          getShortOption   getUUID               iterator
  </code></pre>