How to convert rdd object to dataframe in spark
SparkSession has a number of createDataFrame methods that create a DataFrame given an RDD. I imagine one of these will work for your context. For example: Creates a DataFrame from an RDD containing Rows using the given schema.