I'm trying to use Encoders.bean() to create an encoder for my custom class, but it fails complaining about can't find the schema:
class Person4 { @scala.beans.BeanProperty def setX(x:Int): Unit = {} @scala. beans.BeanProperty def getX():Int = {1} } val personEncoder = Encoders.bean[ Person4](classOf[Person4]) scala> val person_rdd =sc.parallelize(Array( (new Person4(), 1), (new Person4(), 2) )) person_rdd: org.apache.spark.rdd.RDD[( Person4, Int)] = ParallelCollectionRDD[1] at parallelize at <con sole>:31 scala> sqlcontext.createDataFrame(person_rdd) java.lang. UnsupportedOperationException: Schema for type Person4 is not supported at org.apache.spark.sql.catalyst.ScalaReflection$.schemaFor(ScalaReflection. scala:716) at org.apache.spark.sql.catalyst. ScalaReflection$$anonfun$schemaFor$2.apply(ScalaReflection.scala:71 2) at org.apache.spark.sql.catalyst.ScalaReflection$$anonfun$schemaFor$2.apply( ScalaReflection.scala:71 1) at scala.collection. TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) at but if u look at the encoder's schema, it does know it: but the system does seem to understand the schema for "Person4": scala> personEncoder.schema res38: org.apache.spark.sql.types.StructType = StructType(StructField(x,IntegerType,false))