Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ class SQLContext(@transient val sparkContext: SparkContext)
protected def stringOrError[A](f: => A): String =
try f.toString catch { case e: Throwable => e.toString }

def simpleString: String = stringOrError(executedPlan)

override def toString: String =
s"""== Logical Plan ==
|${stringOrError(analyzed)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ trait SchemaRDDLike {
override def toString =
s"""${super.toString}
|== Query Plan ==
|${queryExecution.executedPlan}""".stripMargin.trim

|${queryExecution.simpleString}""".stripMargin.trim

/**
* Saves the contents of this `SchemaRDD` as a parquet file, preserving the schema. Files that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,11 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
val asString = result.map(_.zip(types).map(toHiveString)).map(_.mkString("\t")).toSeq
asString
}

override def simpleString: String =
logical match {
case _: NativeCommand => "<Executed by Hive>"
case _ => executedPlan.toString
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,8 @@ class HiveQuerySuite extends HiveComparisonTest {
hql("SELECT * FROM src TABLESAMPLE(0.1 PERCENT) s")
}

test("SchemaRDD toString") {
hql("SHOW TABLES").toString
hql("SELECT * FROM src").toString
}
}