Skip to content

Commit

Permalink
Fix toString for SchemaRDD NativeCommands.
Browse files Browse the repository at this point in the history
  • Loading branch information
marmbrus committed Apr 7, 2014
1 parent 87d0928 commit 37198fe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
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
}
}

0 comments on commit 37198fe

Please sign in to comment.