使用scala/spark进行数据治理
我有一个ETL来分析大数据,我所有的表都是Spark 2.2.X的数据帧。现在,我必须添加数据治理,以了解数据的来源。例如: 表A使用scala/spark进行数据治理,scala,apache-spark,apache-spark-sql,Scala,Apache Spark,Apache Spark Sql,我有一个ETL来分析大数据,我所有的表都是Spark 2.2.X的数据帧。现在,我必须添加数据治理,以了解数据的来源。例如: 表A | Col1 | Col2 | | ---- | ---- | | test | hello | | test3 | bye | 表B | Col1 | Col2 | | ---- | ---- | | test2 | hey | | test3 | bye | 现在我有了两个表,我做的是通过Col1和Col2+Col2进行连接。结果表:
| Col1 | Col2 |
| ---- | ---- |
| test | hello |
| test3 | bye |
表B
| Col1 | Col2 |
| ---- | ---- |
| test2 | hey |
| test3 | bye |
现在我有了两个表,我做的是通过Col1和Col2+Col2进行连接。结果表:
最终表格
| Col1 | Col2 |
| ---- | ---- |
|test3 | byebye|
我的问题是,Spark DataFrame、API或其他东西中是否有任何函数不会让我对代码进行太多更改,并且我可以显示我在DataFrame中的所有转换?如果您想快速解决此问题,可以查看RDDtoDebugString。您可以在数据帧上调用rdd方法,然后通过此方法显示其沿袭 以下是一个例子: 此代码段以及关于RDD沿袭和toDebugString的详细解释都是可用的
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 []