我有一个ETL来分析大数据,我所有的表都是使用Spark2.2.X的DataFrames。现在,为了知道数据的来源,我必须添加数据治理。例如:
表A
| Col1 | Col2 |
| ---- | ---- |
| test | hello |
| test3 | bye |表B
| Col1 | Col2 |
| ---- | ---- |
| test2 | hey |
| test3 | bye |现在我有了我的两个表,我所做的是Col1和Col2 + Col2的连接。结果表:
最终表格
| Col1 | Col2 |
| ---- | ---- |
|test3 | byebye| 我的问题是,在Spark DataFrame、API或其他什么东西中,有没有什么函数不会让我更改太多代码,并且我可以在我拥有的DataFrame中显示所有的转换?
发布于 2018-07-23 21:22:31
如果你想要一个快速的解决方案,你可以看看RDD#toDebugString。您可以在DataFrame上调用rdd方法,然后通过此方法显示其谱系。
下面是来自Jacek Laskowski's book "Mastering Apache Spark"的一个示例
scala> val wordCount = sc.textFile("README.md").flatMap(_.split("\\s+")).map((_, 1)).reduceByKey(_ + _)
wordCount: org.apache.spark.rdd.RDD[(String, Int)] = ShuffledRDD[21] at reduceByKey at <console>:24
scala> wordCount.toDebugString
res13: String =
(2) ShuffledRDD[21] at reduceByKey at <console>:24 []
+-(2) MapPartitionsRDD[20] at map at <console>:24 []
| MapPartitionsRDD[19] at flatMap at <console>:24 []
| README.md MapPartitionsRDD[18] at textFile at <console>:24 []
| README.md HadoopRDD[17] at textFile at <console>:24 []这个片段,以及关于RDD血统和toDebugString的详细解释都可以在here上找到。
https://stackoverflow.com/questions/51472745
复制相似问题