diff options
author | gatorsmile <gatorsmile@gmail.com> | 2016-09-27 10:52:26 -0700 |
---|---|---|
committer | Herman van Hovell <hvanhovell@databricks.com> | 2016-09-27 10:52:26 -0700 |
commit | 2ab24a7bf6687ec238306772c4c7ddef6ac93e99 (patch) | |
tree | 4426d83e7c804055c5538c7b731e4a0c5b0adf36 /sql/hive/src | |
parent | 120723f934dc386a46a043d2833bfcee60d14e74 (diff) | |
download | spark-2ab24a7bf6687ec238306772c4c7ddef6ac93e99.tar.gz spark-2ab24a7bf6687ec238306772c4c7ddef6ac93e99.tar.bz2 spark-2ab24a7bf6687ec238306772c4c7ddef6ac93e99.zip |
[SPARK-17660][SQL] DESC FORMATTED for VIEW Lacks View Definition
### What changes were proposed in this pull request?
Before this PR, `DESC FORMATTED` does not have a section for the view definition. We should add it for permanent views, like what Hive does.
```
+----------------------------+-------------------------------------------------------------------------------------------------------------------------------------+-------+
|col_name |data_type |comment|
+----------------------------+-------------------------------------------------------------------------------------------------------------------------------------+-------+
|a |int |null |
| | | |
|# Detailed Table Information| | |
|Database: |default | |
|Owner: |xiaoli | |
|Create Time: |Sat Sep 24 21:46:19 PDT 2016 | |
|Last Access Time: |Wed Dec 31 16:00:00 PST 1969 | |
|Location: | | |
|Table Type: |VIEW | |
|Table Parameters: | | |
| transient_lastDdlTime |1474778779 | |
| | | |
|# Storage Information | | |
|SerDe Library: |org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe | |
|InputFormat: |org.apache.hadoop.mapred.SequenceFileInputFormat | |
|OutputFormat: |org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat | |
|Compressed: |No | |
|Storage Desc Parameters: | | |
| serialization.format |1 | |
| | | |
|# View Information | | |
|View Original Text: |SELECT * FROM tbl | |
|View Expanded Text: |SELECT `gen_attr_0` AS `a` FROM (SELECT `gen_attr_0` FROM (SELECT `a` AS `gen_attr_0` FROM `default`.`tbl`) AS gen_subquery_0) AS tbl| |
+----------------------------+-------------------------------------------------------------------------------------------------------------------------------------+-------+
```
### How was this patch tested?
Added a test case
Author: gatorsmile <gatorsmile@gmail.com>
Closes #15234 from gatorsmile/descFormattedView.
Diffstat (limited to 'sql/hive/src')
-rw-r--r-- | sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala index c927e5d802..751e976c7b 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala @@ -506,6 +506,25 @@ class HiveDDLSuite } } + test("desc formatted table for permanent view") { + withTable("tbl") { + withView("view1") { + sql("CREATE TABLE tbl(a int)") + sql("CREATE VIEW view1 AS SELECT * FROM tbl") + assert(sql("DESC FORMATTED view1").collect().containsSlice( + Seq( + Row("# View Information", "", ""), + Row("View Original Text:", "SELECT * FROM tbl", ""), + Row("View Expanded Text:", + "SELECT `gen_attr_0` AS `a` FROM (SELECT `gen_attr_0` FROM " + + "(SELECT `a` AS `gen_attr_0` FROM `default`.`tbl`) AS gen_subquery_0) AS tbl", + "") + ) + )) + } + } + } + test("desc table for data source table using Hive Metastore") { assume(spark.sparkContext.conf.get(CATALOG_IMPLEMENTATION) == "hive") val tabName = "tab1" |