[SPARK-15734][SQL] Avoids printing internal row in explain output

## What changes were proposed in this pull request?

This PR avoids printing internal rows in explain output for some operators.

**Before change:**

```
scala> (1 to 10).toSeq.map(_ => (1,2,3)).toDF().createTempView("df3")
scala> spark.sql("select * from df3 where 1=2").explain(true)
...
== Analyzed Logical Plan ==
_1: int, _2: int, _3: int
Project [_1#37,_2#38,_3#39]
+- Filter (1 = 2)
   +- SubqueryAlias df3
      +- LocalRelation [_1#37,_2#38,_3#39], [[0,1,2,3],[0,1,2,3],[0,1,2,3],[0,1,2,3],[0,1,2,3],[0,1,2,3],[0,1,2,3],[0,1,2,3],[0,1,2,3],[0,1,2,3]]
...
== Physical Plan ==
LocalTableScan [_1#37,_2#38,_3#39]
```

**After change:**

```
scala> spark.sql("select * from df3 where 1=2").explain(true)
...
== Analyzed Logical Plan ==
_1: int, _2: int, _3: int
Project [_1#58,_2#59,_3#60]
+- Filter (1 = 2)
   +- SubqueryAlias df3
      +- LocalRelation [_1#58,_2#59,_3#60]
...
== Physical Plan ==
LocalTableScan <empty>, [_1#58,_2#59,_3#60]
```

## How was this patch tested?
Manual test.

Author: Sean Zhong <seanzhong@databricks.com>

Closes #13471 from clockfly/verbose_breakdown_5.
This commit is contained in:
Sean Zhong 2016-06-02 16:21:33 -07:00 committed by Cheng Lian
parent 4315427657
commit 985d532812
3 changed files with 17 additions and 1 deletions

View file

@ -57,7 +57,13 @@ case class LocalRelation(output: Seq[Attribute], data: Seq[InternalRow] = Nil)
LocalRelation(output.map(_.newInstance()), data).asInstanceOf[this.type]
}
override protected def stringArgs = Iterator(output)
override protected def stringArgs: Iterator[Any] = {
if (data.isEmpty) {
Iterator("<empty>", output)
} else {
Iterator(output)
}
}
override def sameResult(plan: LogicalPlan): Boolean = plan match {
case LocalRelation(otherOutput, otherData) =>

View file

@ -91,6 +91,8 @@ private[sql] case class LogicalRDD(
case _ => false
}
override protected def stringArgs: Iterator[Any] = Iterator(output)
override def producedAttributes: AttributeSet = outputSet
@transient override lazy val statistics: Statistics = Statistics(

View file

@ -48,6 +48,14 @@ private[sql] case class LocalTableScanExec(
}
}
override protected def stringArgs: Iterator[Any] = {
if (rows.isEmpty) {
Iterator("<empty>", output)
} else {
Iterator(output)
}
}
override def executeCollect(): Array[InternalRow] = {
unsafeRows
}