我对用于教育目的的Spark RDD血统或操作员图表的清晰表达感兴趣。我试过了.toDebugString()
,但我很难将它打印得很漂亮(包括换行等)。这里出了什么问题?
Using Python version 3.6.4 (default, Mar 1 2018 18:36:42)
SparkSession available as 'spark'.
>>> sc
<SparkContext master=local[*] appName=PySparkShell>
>>> rdd = sc.parallelize(range(10000))
>>> rdd.toDebugString()
b'(4) PythonRDD[1] at RDD at PythonRDD.scala:48 []\n | ParallelCollectionRDD[0] at parallelize at PythonRDD.scala:175 []'
>>> print(rdd.toDebugString())
b'(4) PythonRDD[1] at RDD at PythonRDD.scala:48 []\n | ParallelCollectionRDD[0] at parallelize at PythonRDD.scala:175 []'
>>>
除了调试字符串之外,还有更好的方法可视化图形吗?
答案 0 :(得分:2)
但是我很难将它打印得很漂亮
因为它是bytes
对象。只需decode
结果:
>>> print(rdd.toDebugString().decode("utf-8"))
(4) PythonRDD[1] at RDD at PythonRDD.scala:48 []
| ParallelCollectionRDD[0] at parallelize at PythonRDD.scala:489 []
还有更好的方法可视化图形吗?
Spark UI中的DAG可视化通常绰绰有余。