How to convert DataFrame to RDD in Scala?

后端 未结 3 1336
甜味超标
甜味超标 2021-02-01 02:11

Can someone please share how one can convert a dataframe to an RDD?

3条回答
  •  梦毁少年i
    2021-02-01 02:19

    I was just looking for my answer and found this post.

    Jean's answer to absolutely correct,adding on that "df.rdd" will return a RDD[Rows]. I need to apply split() once i get RDD. For that we need to convert RDD[Row} to RDD[String]

    val opt=spark.sql("select tags from cvs").map(x=>x.toString()).rdd
    

提交回复
热议问题