aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorgatorsmile <gatorsmile@gmail.com>2016-05-10 11:53:37 +0200
committerHerman van Hovell <hvanhovell@questtec.nl>2016-05-10 11:53:37 +0200
commit570647267055cbe33291232b375e08fa1f5d8e7a (patch)
tree5e13828fce2564824b32df9efcc0733e658c2d3d /sql/hive
parentf45379173bc3a3e657b6229bec2faeb409b6ad53 (diff)
downloadspark-570647267055cbe33291232b375e08fa1f5d8e7a.tar.gz
spark-570647267055cbe33291232b375e08fa1f5d8e7a.tar.bz2
spark-570647267055cbe33291232b375e08fa1f5d8e7a.zip
[SPARK-15215][SQL] Fix Explain Parsing and Output
#### What changes were proposed in this pull request? This PR is to address a few existing issues in `EXPLAIN`: - The `EXPLAIN` options `LOGICAL | FORMATTED | EXTENDED | CODEGEN` should not be 0 or more match. It should 0 or one match. Parser does not allow users to use more than one option in a single command. - The option `LOGICAL` is not supported. Issue an exception when users specify this option in the command. - The output of `EXPLAIN ` contains a weird empty line when the output of analyzed plan is empty. We should remove it. For example: ``` == Parsed Logical Plan == CreateTable CatalogTable(`t`,CatalogTableType(MANAGED),CatalogStorageFormat(None,Some(org.apache.hadoop.mapred.TextInputFormat),Some(org.apache.hadoop.hive.ql.io. HiveIgnoreKeyTextOutputFormat),None,false,Map()),List(CatalogColumn(col,int,true,None)),List(),List(),List(),-1,,1462725171656,-1,Map(),None,None,None), false == Analyzed Logical Plan == CreateTable CatalogTable(`t`,CatalogTableType(MANAGED),CatalogStorageFormat(None,Some(org.apache.hadoop.mapred.TextInputFormat),Some(org.apache.hadoop.hive.ql.io. HiveIgnoreKeyTextOutputFormat),None,false,Map()),List(CatalogColumn(col,int,true,None)),List(),List(),List(),-1,,1462725171656,-1,Map(),None,None,None), false == Optimized Logical Plan == CreateTable CatalogTable(`t`,CatalogTableType(MANAGED),CatalogStorageFormat(None,Some(org.apache.hadoop.mapred.TextInputFormat),Some(org.apache.hadoop.hive.ql.io. HiveIgnoreKeyTextOutputFormat),None,false,Map()),List(CatalogColumn(col,int,true,None)),List(),List(),List(),-1,,1462725171656,-1,Map(),None,None,None), false ... ``` #### How was this patch tested? Added and modified a few test cases Author: gatorsmile <gatorsmile@gmail.com> Closes #12991 from gatorsmile/explainCreateTable.
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala20
1 files changed, 5 insertions, 15 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala
index 542de724cc..17422ca1a0 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala
@@ -18,6 +18,7 @@
package org.apache.spark.sql.hive.execution
import org.apache.spark.sql.QueryTest
+import org.apache.spark.sql.catalyst.parser.ParseException
import org.apache.spark.sql.hive.test.TestHiveSingleton
import org.apache.spark.sql.test.SQLTestUtils
@@ -86,7 +87,7 @@ class HiveExplainSuite extends QueryTest with SQLTestUtils with TestHiveSingleto
|CREATE TABLE t1
|AS
|SELECT * FROM jt
- """.stripMargin).collect().map(_.mkString).mkString
+ """.stripMargin).collect().map(_.mkString).mkString
val shouldContain =
"== Parsed Logical Plan ==" :: "== Analyzed Logical Plan ==" :: "Subquery" ::
@@ -115,19 +116,8 @@ class HiveExplainSuite extends QueryTest with SQLTestUtils with TestHiveSingleto
"== Physical Plan =="
)
- checkKeywordsExist(sql("EXPLAIN EXTENDED CODEGEN SELECT 1"),
- "WholeStageCodegen",
- "Generated code:",
- "/* 001 */ public Object generate(Object[] references) {",
- "/* 002 */ return new GeneratedIterator(references);",
- "/* 003 */ }"
- )
-
- checkKeywordsNotExist(sql("EXPLAIN EXTENDED CODEGEN SELECT 1"),
- "== Parsed Logical Plan ==",
- "== Analyzed Logical Plan ==",
- "== Optimized Logical Plan ==",
- "== Physical Plan =="
- )
+ intercept[ParseException] {
+ sql("EXPLAIN EXTENDED CODEGEN SELECT 1")
+ }
}
}