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

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

问题描述

我很熟悉 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).

使用

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)

您可以使用 toJSON prettyJson 将输出另存为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天全站免登陆