title: value toDF is not a member of org.apache.spark.rdd.RDD
body: <p><strong>Exception :</strong> </p>
  
  <pre class="lang-scala prettyprint-override"><code>val people = sc.textFile("resources/people.txt").map(_.split(",")).map(p =&gt; Person(p(0), p(1).trim.toInt)).toDF()
  value toDF is not a member of org.apache.spark.rdd.RDD[Person]
  </code></pre>
  
  <p>Here is <code>TestApp.scala</code> file:</p>
  
  <pre class="lang-scala prettyprint-override"><code>package main.scala
  
  import org.apache.spark.SparkContext
  import org.apache.spark.SparkContext._
  import org.apache.spark.SparkConf
  
  
  case class Record1(k: Int, v: String)
  
  
  object RDDToDataFramesWithCaseClasses {
  
      def main(args: Array[String]) {
          val conf = new SparkConf().setAppName("Simple Spark SQL Application With RDD To DF")
  
          // sc is an existing SparkContext.
          val sc = new SparkContext(conf)
  
          val sqlContext = new SQLContext(sc)
  
          // this is used to implicitly convert an RDD to a DataFrame.
          import sqlContext.implicits._
  
          // Define the schema using a case class.
          // Note: Case classes in Scala 2.10 can support only up to 22 fields. To work around this limit,package main.scala
  </code></pre>
  
  <p>And  <code>TestApp.scala</code></p>
  
  <pre class="lang-scala prettyprint-override"><code>import org.apache.spark.SparkContext    
  import org.apache.spark.SparkContext._
  import org.apache.spark.SparkConf
  
  
  case class Record1(k: Int, v: String)
  
  
  object RDDToDataFramesWithCaseClasses {
      def main(args: Array[String]) {
          val conf = new SparkConf().setAppName("RDD To DF")
  
          // sc is an existing SparkContext.
          // you can use custom classes that implement the Product interface.
          case class Person(name: String, age: Int)
  
          // Create an RDD of Person objects and register it as a table.
          val people = sc.textFile("resources/people.txt").map(_.split(",")).map(p =&gt; Person(p(0), p(1).trim.toInt)).toDF() 
          people.registerTempTable("people")
  
          // SQL statements can be run by using the sql methods provided by sqlContext.
          val teenagers = sqlContext.sql("SELECT name, age FROM people WHERE age &gt;= 13 AND age &lt;= 19")
  
          // The results of SQL queries are DataFrames and support all the normal RDD operations.
          // The columns of a row in the result can be accessed by field index:
          teenagers.map(t =&gt; "Name: " + t(0)).collect().foreach(println)
  
          // or by field name:
          teenagers.map(t =&gt; "Name: " + t.getAs[String]("name")).collect().foreach(println)
  
          // row.getValuesMap[T] retrieves multiple columns at once into a Map[String, T]
  
          teenagers.map(_.getValuesMap[Any](List("name", "age"))).collect().foreach(println)
  
          // Map("name" -&gt; "Justin", "age" -&gt; 19)
  
      }
  }
  </code></pre>
  
  <p>And <strong>SBT File</strong></p>
  
  <pre class="lang-scala prettyprint-override"><code>name := "SparkScalaRDBMS"
  version := "1.0"
  scalaVersion := "2.11.7"
  libraryDependencies += "org.apache.spark" %% "spark-core" % "1.5.1"
  libraryDependencies += "org.apache.spark" %% "spark-sql" % "1.5.1"
  </code></pre>