diff options
author | Josh Rosen <joshrosen@databricks.com> | 2016-03-08 16:28:22 -0800 |
---|---|---|
committer | Josh Rosen <joshrosen@databricks.com> | 2016-03-08 16:28:22 -0800 |
commit | 81f54acc9cc0fb9d4ee552f6f56a26c78654a33b (patch) | |
tree | c4d97d3ed232f3557b89bdd356cc0376cf662033 | |
parent | e430614eae53c8864b31a1dc64db83e27100d1d9 (diff) | |
download | spark-81f54acc9cc0fb9d4ee552f6f56a26c78654a33b.tar.gz spark-81f54acc9cc0fb9d4ee552f6f56a26c78654a33b.tar.bz2 spark-81f54acc9cc0fb9d4ee552f6f56a26c78654a33b.zip |
[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.
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/execution/ui/SparkPlanGraph.scala | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/ui/SparkPlanGraph.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/ui/SparkPlanGraph.scala index 12e586ada5..83372aa2e9 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/ui/SparkPlanGraph.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/ui/SparkPlanGraph.scala @@ -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 |