提交 81f54acc 编写于 作者: J Josh Rosen

[SPARK-13755] Escape quotes in SQL plan visualization node labels

When generating Graphviz DOT files in the SQL query visualization we need to escape double-quotes inside node labels. This is a followup to #11309, which fixed a similar graph in Spark Core's DAG visualization.

Author: Josh Rosen <joshrosen@databricks.com>

Closes #11587 from JoshRosen/graphviz-escaping.
上级 e430614e
......@@ -21,6 +21,8 @@ import java.util.concurrent.atomic.AtomicLong
import scala.collection.mutable
import org.apache.commons.lang3.StringEscapeUtils
import org.apache.spark.sql.execution.SparkPlanInfo
import org.apache.spark.sql.execution.metric.SQLMetrics
......@@ -136,16 +138,14 @@ private[ui] class SparkPlanGraphNode(
}
if (values.nonEmpty) {
// If there are metrics, display each entry in a separate line. We should use an escaped
// "\n" here to follow the dot syntax.
//
// If there are metrics, display each entry in a separate line.
// Note: whitespace between two "\n"s is to create an empty line between the name of
// SparkPlan and metrics. If removing it, it won't display the empty line in UI.
builder ++= "\\n \\n"
builder ++= values.mkString("\\n")
builder ++= "\n \n"
builder ++= values.mkString("\n")
}
s""" $id [label="${builder.toString()}"];"""
s""" $id [label="${StringEscapeUtils.escapeJava(builder.toString())}"];"""
}
}
......@@ -162,7 +162,7 @@ private[ui] class SparkPlanGraphCluster(
override def makeDotNode(metricsValue: Map[Long, String]): String = {
s"""
| subgraph cluster${id} {
| label=${name};
| label="${StringEscapeUtils.escapeJava(name)}";
| ${nodes.map(_.makeDotNode(metricsValue)).mkString(" \n")}
| }
""".stripMargin
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册