使用什么工具来可视化逻辑和物理查询计划? [英] What tools to use to visualize logical and physical query plans?

查看:22
本文介绍了使用什么工具来可视化逻辑和物理查询计划?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很熟悉 explain()(也是 WebUI).我很好奇是否有任何工具可以在优化之前/之后生成逻辑/物理计划的树结构图像.那就是 explain() 作为图像返回的信息.

I am familiar explain() (also WebUI). I was curious whether there are any tools that generate an image of the tree structure of the logical/physical plan before/after optimizations. That is the information returned by explain() as an image.

推荐答案

像 PNG 或 JPG 这样的图片?我自己从未听说过,但您可以使用 Web UI(您已经提到过)查看物理计划.

A picture like a PNG or JPG? Never heard of one myself, but you can see the physical plan using web UI (that you've already mentioned).

查询执行的其他阶段可使用 TreeNode 方法(在许多可以帮助你的方法中)给你我最喜欢的 numberedTreeString.

The other phases of query execution are available using TreeNode methods which (among many methods that could help you out) give you my favorite 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)

您可以使用 toJSONprettyJson 将输出保存为 JSON 以生成 PNG(但我自己从未尝试过).

You can save the output as JSON using toJSON or prettyJson to generate PNG (but I've never tried it out myself).

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
    } ] ]
  } ]
} ]

这篇关于使用什么工具来可视化逻辑和物理查询计划?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆