title: spark schema rdd to RDD
body: <p>I would like to do word count in spark , I created a rdd using spark sql to extract distinct tweets from data set.
  I would like to use split function on top of RDD but its not allowing me to do so.</p>
  
  <p>Error:-
  valuse split is not a member of org.apache.spark.sql.SchemaRdd</p>
  
  <p>Spark Code that doesn't work to do word count:-</p>
  
  <pre><code>val disitnct_tweets=hiveCtx.sql("select distinct(text) from tweets_table where text &lt;&gt; ''")
  val distinct_tweets_List=sc.parallelize(List(distinct_tweets))
  
  //tried split on both the rdd disnt worked
  
  distinct_tweets.flatmap(line =&gt; line.split(" ")).map(word =&gt; (word,1)).reduceByKey(_+_)
  
  distinct_tweets_List.flatmap(line =&gt; line.split(" ")).map(word =&gt; (word,1)).reduceByKey(_+_)
  </code></pre>
  
  <p>But when I output the data from sparksql to a file and load it again and run split it works.</p>
  
  <p>Example Code that works:-</p>
  
  <pre><code>val distinct_tweets=hiveCtx.sql("select dsitinct(text) from tweets_table where text &lt;&gt; ''")
  val distinct_tweets_op=distinct_tweets.collect()
  val rdd=sc.parallelize(distinct_tweets_op)
  rdd.saveAsTextFile("/home/cloudera/bdp/op")
  val textFile=sc.textFile("/home/cloudera/bdp/op/part-00000")
  val counts=textFile.flatMap(line =&gt; line.split(" ")).map(word =&gt; (word,1)).reduceByKey(_+_)
  counts.SaveAsTextFile("/home/cloudera/bdp/wordcount")
  </code></pre>
  
  <p>I need a answer instead of writing to file and loading again to do my split function is there a work around to make split function work</p>
  
  <p>Thanks</p>