Hope you are doing well.
The input should be like the below sample. We cannot keep column1 and column2 in dataset because it will also be taken as a value so the above should the dataset.
case class Demo(Column1: String, Column2: String )
val rdd = sc.textFile("file:///home/edureka/Desktop/myfile").map(_.split(" ")).map(x=>Demo(x(0),x(1))).toDF
Please try and let us know if you face any issue.
We are eagerly waiting for your response.