Repository: spark
Updated Branches:
  refs/heads/branch-1.4 6df71eb8c -> 53d6ab51b


[SPARK-7686] [SQL] DescribeCommand is assigned wrong output attributes in 
SparkStrategies

In `SparkStrategies`, `RunnableDescribeCommand` is called with the output 
attributes of the table being described rather than the attributes for the 
`describe` command's output.  I discovered this issue because it caused type 
conversion errors in some UnsafeRow conversion code that I'm writing.

Author: Josh Rosen <[email protected]>

Closes #6217 from JoshRosen/SPARK-7686 and squashes the following commits:

953a344 [Josh Rosen] Fix SPARK-7686 with a simple change in SparkStrategies.
a4eec9f [Josh Rosen] Add failing regression test for SPARK-7686

(cherry picked from commit 564562874f589c4c8bcabcd9d6eb9a6b0eada938)
Signed-off-by: Reynold Xin <[email protected]>


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

Branch: refs/heads/branch-1.4
Commit: 53d6ab51b21de9a1bfc355f8493fcd6e9159ab07
Parents: 6df71eb
Author: Josh Rosen <[email protected]>
Authored: Sun May 17 11:59:28 2015 -0700
Committer: Reynold Xin <[email protected]>
Committed: Sun May 17 11:59:35 2015 -0700

----------------------------------------------------------------------
 .../scala/org/apache/spark/sql/execution/SparkStrategies.scala | 4 ++--
 .../test/scala/org/apache/spark/sql/sources/DDLTestSuite.scala | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/53d6ab51/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala
----------------------------------------------------------------------
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala
index af0029c..3f6a034 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala
@@ -354,10 +354,10 @@ private[sql] abstract class SparkStrategies extends 
QueryPlanner[SparkPlan] {
       case c: CreateTableUsingAsSelect if !c.temporary =>
         sys.error("Tables created with SQLContext must be TEMPORARY. Use a 
HiveContext instead.")
 
-      case LogicalDescribeCommand(table, isExtended) =>
+      case describe @ LogicalDescribeCommand(table, isExtended) =>
         val resultPlan = self.sqlContext.executePlan(table).executedPlan
         ExecutedCommand(
-          RunnableDescribeCommand(resultPlan, resultPlan.output, isExtended)) 
:: Nil
+          RunnableDescribeCommand(resultPlan, describe.output, isExtended)) :: 
Nil
 
       case _ => Nil
     }

http://git-wip-us.apache.org/repos/asf/spark/blob/53d6ab51/sql/core/src/test/scala/org/apache/spark/sql/sources/DDLTestSuite.scala
----------------------------------------------------------------------
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/sources/DDLTestSuite.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/sources/DDLTestSuite.scala
index 6664e8d..f5106f6 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/sources/DDLTestSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/sources/DDLTestSuite.scala
@@ -99,4 +99,10 @@ class DDLTestSuite extends DataSourceTest {
         Row("arrayType", "array<string>", ""),
         Row("structType", "struct<f1:string,f2:int>", "")
       ))
+
+  test("SPARK-7686 DescribeCommand should have correct physical plan output 
attributes") {
+    val attributes = sql("describe 
ddlPeople").queryExecution.executedPlan.output
+    assert(attributes.map(_.name) === Seq("col_name", "data_type", "comment"))
+    assert(attributes.map(_.dataType).toSet === Set(StringType))
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to