Closed msrvp closed 7 years ago
I looked into this and the problem is that your sdf
DataFrame doesn't have the right schema.
The problem here is that you're using the createDataFrame
overload which accepts a JavaBean class and looks for bean properties, but, by default, Scala case classes don't follow the JavaBean spec (see http://alvinalexander.com/scala/scala-javabeans-beanproperty-annotation).
Instead, you should either use the createDataFrame
overload which takes an implict ClassTag for a Product
subtype, e.g. val sdf = sqlContext.createDataFrame[ARecord](ardd)
.
I have an RDD[String](which is actually a JSON).
Wrote the following code:
However, when I try to view the avro file created, it is empty:
The dataframe content becomes empty.
However, if I create the dataframe without the schema (ARecord), it retains all the data. However, on converting to avro I get the following exception: