Github user rednaxelafx commented on a diff in the pull request:
https://github.com/apache/spark/pull/22429#discussion_r218235962
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala ---
@@ -189,23 +192,32 @@ class QueryExecution(val sparkSession: SparkSession,
val logical: LogicalPlan) {
""".stripMargin.trim
}
+ private def writeOrError(writer: Writer)(f: Writer => Unit): Unit =
+ try f(writer) catch { case e: AnalysisException =>
writer.write(e.toString) }
+
+ private def writePlans(writer: Writer): Unit = {
+ writer.write("== Parsed Logical Plan ==\n")
+ writeOrError(writer)(logical.treeString(_, verbose = true, addSuffix =
false))
+ writer.write("== Analyzed Logical Plan ==\n")
+ writeOrError(writer) { writer =>
+ analyzed.output.foreach(o => writer.write(s"${o.name}:
${o.dataType.simpleString}"))
--- End diff --
If you want to get the best out of this approach, it might be better to
avoid string interpolation here and do the explicit `writer.write` calls for
the things you're interpolating on.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]