scala Spark 将数据集转换为 RDD

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38796520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 08:32:36  来源:igfitidea点击:

Spark converting a Dataset to RDD

javascalaapache-spark

提问by TakeSoUp

I have a Dataset[String] and need to convert to a RDD[String]. How?

我有一个 Dataset[String],需要转换为 RDD[String]。如何?

Note: I've recently migrated from spark 1.6 to spark 2.0. Some of my clients were expecting RDD but now Spark gives me Dataset.

注意:我最近从 spark 1.6 迁移到 spark 2.0。我的一些客户期待 RDD,但现在 Spark 给了我数据集。

回答by cheseaux

As stated in the scala API documentationyou can call .rddon your Dataset :

如 scala API 文档中所述,您可以调用.rdd您的数据集:

val myRdd : RDD[String] = ds.rdd

回答by user3215496

Dataset is a strong typed Dataframe, so both Dataset and Dataframe could use .rdd to convert to a RDD.

Dataset 是强类型的 Dataframe,因此 Dataset 和 Dataframe 都可以使用 .rdd 转换为 RDD。