title: How to create a sample dataframe in Scala / Spark
body: <p>I'm trying to create a simple <code>DataFrame</code> as follows:</p>
  
  <pre><code>import sqlContext.implicits._
  
  val lookup = Array("one", "two", "three", "four", "five")
  
  val theRow = Array("1",Array(1,2,3), Array(0.1,0.4,0.5))
  
  val theRdd = sc.makeRDD(theRow)
  
  case class X(id: String, indices: Array[Integer], weights: Array[Float] )
  
  val df = theRdd.map{
      case Array(s0,s1,s2) =&gt;    X(s0.asInstanceOf[String],s1.asInstanceOf[Array[Integer]],s2.asInstanceOf[Array[Float]])
  }.toDF()
  
  df.show()
  </code></pre>
  
  <p>df is defined as</p>
  
  <pre><code>df: org.apache.spark.sql.DataFrame = [id: string, indices: array&lt;int&gt;, weights: array&lt;float&gt;]
  </code></pre>
  
  <p>which is what I want.</p>
  
  <p>Upon executing, I get </p>
  
  <blockquote>
    <p>org.apache.spark.SparkException: Job aborted due to stage failure: Task 1 in stage 13.0 failed 1 times, most recent failure: Lost task 1.0 in stage 13.0 (TID 50, localhost): scala.MatchError: 1 (of class java.lang.String)</p>
  </blockquote>
  
  <p>Where is this MatchError coming from? And, is there a simpler way to create sample <code>DataFrames</code> programmatically?</p>