Hello I am converting some py code to scala. This works in python:
rdd = sc.parallelize([('apple',1),('orange',2)]) rdd.toDF(['fruit','num']).show()
+------+---+ | fruit|num| +------+---+ | apple| 1| |orange| 2| +------+---+ And in scala: scala> rdd.toDF("fruit","num").show() +------+---+ | fruit|num| +------+---+ | apple| 1| |orange| 2| +------+---+ But I saw many code that use a case class for translation. scala> case class Fruit(fruit:String,num:Int) defined class Fruit scala> rdd.map{case (x,y) => Fruit(x,y) }.toDF().show() +------+---+ | fruit|num| +------+---+ | apple| 1| |orange| 2| +------+---+ Do you know why to use a "case class" here? thanks. --------------------------------------------------------------------- To unsubscribe e-mail: user-unsubscr...@spark.apache.org