sav*_*ava 5 apache-spark apache-spark-sql
我很熟悉explain()(还有WebUI)。我很好奇是否有任何工具可以生成优化前后逻辑/物理计划的树结构图像。explain()这是作为图像返回的信息。
PNG 或 JPG 之类的图片?我自己从未听说过,但您可以使用 Web UI 查看物理计划(您已经提到过)。
查询执行的其他阶段可以使用TreeNode方法来实现,这些方法(在许多可以帮助您的方法中)为您提供了我最喜欢的numberedTreeString。
scala> println(q.queryExecution.analyzed.numberedTreeString)
00 Range (0, 5, step=1, splits=Some(8))
scala> println(q.queryExecution.executedPlan.numberedTreeString)
00 *Range (0, 5, step=1, splits=8)
Run Code Online (Sandbox Code Playgroud)
toJSON您可以使用或生成 PNG将输出保存为 JSON prettyJson(但我自己从未尝试过)。
scala> println(q.queryExecution.executedPlan.prettyJson)
[ {
"class" : "org.apache.spark.sql.execution.WholeStageCodegenExec",
"num-children" : 1,
"child" : 0
}, {
"class" : "org.apache.spark.sql.execution.RangeExec",
"num-children" : 0,
"range" : [ {
"class" : "org.apache.spark.sql.catalyst.plans.logical.Range",
"num-children" : 0,
"start" : 0,
"end" : 5,
"step" : 1,
"numSlices" : 8,
"output" : [ [ {
"class" : "org.apache.spark.sql.catalyst.expressions.AttributeReference",
"num-children" : 0,
"name" : "id",
"dataType" : "long",
"nullable" : false,
"metadata" : { },
"exprId" : {
"product-class" : "org.apache.spark.sql.catalyst.expressions.ExprId",
"id" : 0,
"jvmId" : "cb497d01-3b90-42a7-9ebf-ebe85578f763"
},
"isGenerated" : false
} ] ]
} ]
} ]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2360 次 |
| 最近记录: |