spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: [SQL] SPARK-1427 Fix toString for SchemaRDD NativeCommands.
Date Mon, 07 Apr 2014 08:46:53 GMT
Repository: spark
Updated Branches:
  refs/heads/master accd0999f -> b5bae849d


[SQL] SPARK-1427 Fix toString for SchemaRDD NativeCommands.

Author: Michael Armbrust <michael@databricks.com>

Closes #343 from marmbrus/toStringFix and squashes the following commits:

37198fe [Michael Armbrust] Fix toString for SchemaRDD NativeCommands.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/b5bae849
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/b5bae849
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/b5bae849

Branch: refs/heads/master
Commit: b5bae849dbdf833a80746b705732b8c86971fddc
Parents: accd099
Author: Michael Armbrust <michael@databricks.com>
Authored: Mon Apr 7 01:46:50 2014 -0700
Committer: Reynold Xin <rxin@apache.org>
Committed: Mon Apr 7 01:46:50 2014 -0700

----------------------------------------------------------------------
 sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala  | 2 ++
 .../src/main/scala/org/apache/spark/sql/SchemaRDDLike.scala    | 3 +--
 .../src/main/scala/org/apache/spark/sql/hive/HiveContext.scala | 6 ++++++
 .../org/apache/spark/sql/hive/execution/HiveQuerySuite.scala   | 4 ++++
 4 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/b5bae849/sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala b/sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala
index 36059c6..3193787 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala
@@ -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)}

http://git-wip-us.apache.org/repos/asf/spark/blob/b5bae849/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDDLike.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDDLike.scala b/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDDLike.scala
index 840803a..3dd9897 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDDLike.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDDLike.scala
@@ -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

http://git-wip-us.apache.org/repos/asf/spark/blob/b5bae849/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
index f66a667..3534584 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
@@ -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
+      }
   }
 }

http://git-wip-us.apache.org/repos/asf/spark/blob/b5bae849/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 0c27498..a09667a 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
@@ -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
+  }
 }


Mime
View raw message