title: Trying to run SparkSQL over Spark Streaming
body: <p>I am trying to run SQL queries over streaming data in spark. This looks pretty straight forward but when I try it, I get the error <strong>table not found : <em>tablename</em>></strong>. It unable to find the table I've registered.</p>
  
  <p>Using Spark SQL with batch data works fine so I'm thinking it has to do with how I'm calling streamingcontext.start(). Any ideas what is the issue? Here is the code:</p>
  
  <pre><code>import org.apache.spark.streaming.{Seconds, StreamingContext}
  import org.apache.spark.streaming.StreamingContext._
  import org.apache.spark.sql.SQLContext
  
  object Streaming {
  
  def main(args: Array[String]) {
  
      val sparkConf = new SparkConf().setMaster("local").setAppName("HdfsWordCount")
      val sc = new SparkContext(sparkConf)
      // Create the context
      val ssc = new StreamingContext(sc, Seconds(2))
  
      val sqc = new SQLContext(sc);
      import sqc.createSchemaRDD
  
      // Create the FileInputDStream on the directory and use the
      // stream to count words in new files created
      val lines = ssc.textFileStream("C:/Users/pravesh.jain/Desktop/people.txt")
      lines.foreachRDD(rdd=&gt;rdd.map(_.split(",")).map(p =&gt; Persons(p(0), p(1).trim.toInt)).registerAsTable("data"))
      // lines.foreachRDD(rdd=&gt;rdd.foreach(println))
      val teenagers = sqc.sql("SELECT name FROM data WHERE age &gt;= 13 AND age &lt;= 19")
      ssc.start()
      ssc.awaitTermination()
    }
  }
  </code></pre>
  
  <p>Any suggestions welcome. Thanks.</p>