Q:

Spark: convert rdd[row] to dataframe where one of the columns in the row is a list

I have a rdd[row] with the following data for each row  
[guid, List(peopleObjects)]  
["123", List(peopleObjects1, peopleObjects2, peopleObjects3)]

I want to convert this to a dataframe
I am using the following code  
val personStructureType = new StructType()
    .add(StructField("guid", StringType, true))
    .add(StructField("personList", StringType, true))  
val personDF = hiveContext.createDataFrame(personRDD, personStructureType)

Should I be using a different datatype for my schema instead of StringType?
If my list is just a string it works but when its a List I get the following error  
scala.MatchError: List(personObject1, personObject2, personObject3) (of class scala.collection.immutable.$colon$colon)
    at org.apache.spark.sql.catalyst.CatalystTypeConverters$StringConverter$.toCatalystImpl(CatalystTypeConverters.scala:295)
    at org.apache.spark.sql.catalyst.CatalystTypeConverters$StringConverter$.toCatalystImpl(CatalystTypeConverters.scala:294)
    at org.apache.spark.sql.catalyst.CatalystTypeConverters$CatalystTypeConverter.toCatalyst(CatalystTypeConverters.scala:102)
    at org.apache.spark.sql.catalyst.CatalystTypeConverters$StructConverter.toCatalystImpl(CatalystTypeConverters.scala:260)
    at org.apache.spark.sql.catalyst.CatalystTypeConverters$StructConverter.toCatalystImpl(CatalystTypeConverters.scala:250)
    at org.apache.spark.sql.catalyst.CatalystTypeConverters$CatalystTypeConverter.toCatalyst(CatalystTypeConverters.scala:102)
    at org.apache.spark.sql.catalyst.CatalystTypeConverters$$anonfun$createToCatalystConverter$2.apply(CatalystTypeConverters.scala:401)
    at org.apache.spark.sql.SQLContext$$anonfun$7.apply(SQLContext.scala:445)
    at org.apache.spark.sql.SQLContext$$anonfun$7.apply(SQLContext.scala:445)
    at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
    at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
    at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
    at org.apache.spark.util.collection.ExternalSorter.insertAll(ExternalSorter.scala:219)
    at org.apache.spark.shuffle.sort.SortShuffleWriter.write(SortShuffleWriter.scala:73)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:73)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41)
    at org.apache.spark.scheduler.Task.run(Task.scala:88)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745) 

A:

It's not entirely clear what you are trying to do, but a better way to do what you are trying to do is to create a case class and then just map your RDD lines to the case class, then call toDF.
Something like:
case class MyClass(guid: Int, peopleObjects: List[String])

val rdd = sc.parallelize(Array((123,List("a","b")),(1232,List("b","d"))))

val df =  rdd.map(r => MyClass(r._1, r._2)).toDF
df.show
+----+-------------+
|guid|peopleObjects|
+----+-------------+
| 123|       [a, b]|
|1232|       [b, d]|
+----+-------------+

Or you can do it the long-hand way, but without using the case class, like this:
val df = sqlContext.createDataFrame(
  rdd.map(r => Row(r._1, r._2)),
  StructType(Array(
    StructField("guid",IntegerType),
    StructField("peopleObjects", ArrayType(StringType))
  ))
)

