Skip to content

Commit 76f3c73

Browse files
mateizrxin
authored andcommitted
[SPARK-14356] Update spark.sql.execution.debug to work on Datasets
## What changes were proposed in this pull request? Update DebugQuery to work on Datasets of any type, not just DataFrames. ## How was this patch tested? Added unit tests, checked in spark-shell. Author: Matei Zaharia <matei@databricks.com> Closes #12140 from mateiz/debug-dataset.
1 parent 3f749f7 commit 76f3c73

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/debug/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ package object debug {
7777
}
7878

7979
/**
80-
* Augments [[DataFrame]]s with debug methods.
80+
* Augments [[Dataset]]s with debug methods.
8181
*/
82-
implicit class DebugQuery(query: DataFrame) extends Logging {
82+
implicit class DebugQuery(query: Dataset[_]) extends Logging {
8383
def debug(): Unit = {
8484
val plan = query.queryExecution.executedPlan
8585
val visited = new collection.mutable.HashSet[TreeNodeRef]()

sql/core/src/test/scala/org/apache/spark/sql/execution/debug/DebuggingSuite.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ package org.apache.spark.sql.execution.debug
1919

2020
import org.apache.spark.SparkFunSuite
2121
import org.apache.spark.sql.test.SharedSQLContext
22+
import org.apache.spark.sql.test.SQLTestData.TestData
2223

2324
class DebuggingSuite extends SparkFunSuite with SharedSQLContext {
2425

2526
test("DataFrame.debug()") {
2627
testData.debug()
2728
}
2829

30+
test("Dataset.debug()") {
31+
import testImplicits._
32+
testData.as[TestData].debug()
33+
}
34+
2935
test("debugCodegen") {
3036
val res = codegenString(sqlContext.range(10).groupBy("id").count().queryExecution.executedPlan)
3137
assert(res.contains("Subtree 1 / 2"))

0 commit comments

Comments
 (0)