简体   繁体   English

如何在不运行的情况下获取Apache Spark作业的DAG?

[英]How can I obtain the DAG of an Apache Spark job without running it?

I have some Scala code that I can run with Spark using spark-submit. 我有一些Scala代码,我可以使用spark-submit与Spark一起运行。 From what I understood, Spark creates a DAG in order to schedule the operation. 根据我的理解,Spark创建了一个DAG以便安排操作。

Is there a way to retrieve this DAG without actually performing the heavy operations, eg just by analyzing the code ? 有没有办法检索这个DAG而不实际执行繁重的操作,例如只是通过分析代码?

I would like a useful representation such as a data structure or at least a written representation, not the DAG visualization. 我想要一个有用的表示,如数据结构或至少一个书面表示,而不是DAG可视化。

If you are using dataframes (spark sql) you can use df.explain(true) to get the plan and all operations (before and after optimization). 如果您使用的是数据帧(spark sql),则可以使用df.explain(true)来获取计划和所有操作(优化前后)。

If you are using rdd you can use rdd.toDebugString to get a string representation and rdd.dependencies to get the tree itself. 如果您使用的是rdd,则可以使用rdd.toDebugString来获取字符串表示形式,使用rdd.dependencies来获取树本身。

If you use these without the actual action you would get a representation of what is going to happen without actually doing the heavy lifting. 如果您在没有实际操作的情况下使用它们,您将获得在没有实际执行繁重任务的情况下将会发生什么的表示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM