You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by hv...@apache.org on 2016/04/03 15:33:44 UTC
spark git commit: [SPARK-14350][SQL] EXPLAIN output should be in a
single cell
Repository: spark
Updated Branches:
refs/heads/master 2262a9335 -> 1f0c5dceb
[SPARK-14350][SQL] EXPLAIN output should be in a single cell
## What changes were proposed in this pull request?
EXPLAIN output should be in a single cell.
**Before**
```
scala> sql("explain select 1").collect()
res0: Array[org.apache.spark.sql.Row] = Array([== Physical Plan ==], [WholeStageCodegen], [: +- Project [1 AS 1#1]], [: +- INPUT], [+- Scan OneRowRelation[]])
```
**After**
```
scala> sql("explain select 1").collect()
res1: Array[org.apache.spark.sql.Row] =
Array([== Physical Plan ==
WholeStageCodegen
: +- Project [1 AS 1#4]
: +- INPUT
+- Scan OneRowRelation[]])
```
Or,
```
scala> sql("explain select 1").head
res1: org.apache.spark.sql.Row =
[== Physical Plan ==
WholeStageCodegen
: +- Project [1 AS 1#5]
: +- INPUT
+- Scan OneRowRelation[]]
```
Please note that `Spark-shell(Scala-shell)` trims long string output. So, you may need to use `println` to get full strings.
```
scala> println(sql("explain codegen select 'a' as a group by 1").head)
[Found 2 WholeStageCodegen subtrees.
== Subtree 1 / 2 ==
WholeStageCodegen
...
/* 059 */ }
/* 060 */ }
]
```
## How was this patch tested?
Pass the Jenkins tests. (Testcases are updated.)
Author: Dongjoon Hyun <do...@apache.org>
Closes #12137 from dongjoon-hyun/SPARK-14350.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/1f0c5dce
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/1f0c5dce
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/1f0c5dce
Branch: refs/heads/master
Commit: 1f0c5dcebba1f9d1149043a496e0175f78252bae
Parents: 2262a93
Author: Dongjoon Hyun <do...@apache.org>
Authored: Sun Apr 3 15:33:29 2016 +0200
Committer: Herman van Hovell <hv...@questtec.nl>
Committed: Sun Apr 3 15:33:29 2016 +0200
----------------------------------------------------------------------
.../scala/org/apache/spark/sql/execution/command/commands.scala | 2 +-
.../scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/1f0c5dce/sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala
index 4bc62cd..4eb8d7f 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala
@@ -253,7 +253,7 @@ case class ExplainCommand(
} else {
queryExecution.simpleString
}
- outputString.split("\n").map(Row(_))
+ Seq(Row(outputString))
} catch { case cause: TreeNodeException[_] =>
("Error occurred during query planning: \n" + cause.getMessage).split("\n").map(Row(_))
}
http://git-wip-us.apache.org/repos/asf/spark/blob/1f0c5dce/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
index 5825906..5450368 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
@@ -707,7 +707,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
def isExplanation(result: DataFrame): Boolean = {
val explanation = result.select('plan).collect().map { case Row(plan: String) => plan }
- explanation.contains("== Physical Plan ==")
+ explanation.head.startsWith("== Physical Plan ==")
}
test("SPARK-1704: Explain commands as a DataFrame") {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org