GitHub user dongjoon-hyun opened a pull request:

    https://github.com/apache/spark/pull/15168

    [SPARK-17612][SQL] Support `DESCRIBE table PARTITION` SQL syntax

    ## What changes were proposed in this pull request?
    
    This PR implements `DESCRIBE table PARTITION` SQL Syntax again. It was 
supported until Spark 1.6.2, but was dropped since 2.0.0.
    
    **Spark 1.6.2**
    ```
    scala> sql("CREATE TABLE partitioned_table (a STRING, b INT) PARTITIONED BY 
(c STRING, d STRING)")
    res1: org.apache.spark.sql.DataFrame = [result: string]
    
    scala> sql("ALTER TABLE partitioned_table ADD PARTITION (c='Us', d=1)")
    res2: org.apache.spark.sql.DataFrame = [result: string]
    
    scala> sql("DESC partitioned_table PARTITION (c='Us', d=1)").show(false)
    +----------------------------------------------------------------+
    |result                                                          |
    +----------------------------------------------------------------+
    |a                      string                                        |
    |b                      int                                           |
    |c                      string                                        |
    |d                      string                                        |
    |                                                                           
 |
    |# Partition Information                                                    
  |
    |# col_name             data_type               comment             |
    |                                                                           
 |
    |c                      string                                        |
    |d                      string                                        |
    +----------------------------------------------------------------+
    ```
    
    **Spark 2.0**
    - **Before**
    ```
    scala> sql("CREATE TABLE partitioned_table (a STRING, b INT) PARTITIONED BY 
(c STRING, d STRING)")
    res0: org.apache.spark.sql.DataFrame = []
    
    scala> sql("ALTER TABLE partitioned_table ADD PARTITION (c='Us', d=1)")
    res1: org.apache.spark.sql.DataFrame = []
    
    scala> sql("DESC partitioned_table PARTITION (c='Us', d=1)").show(false)
    org.apache.spark.sql.catalyst.parser.ParseException:
    Unsupported SQL statement
    == SQL ==
    DESC partitioned_table PARTITION (c='Us', d=1)
      at 
org.apache.spark.sql.catalyst.parser.AbstractSqlParser$$anonfun$parsePlan$1.apply(ParseDriver.scala:58)
      at 
org.apache.spark.sql.catalyst.parser.AbstractSqlParser$$anonfun$parsePlan$1.apply(ParseDriver.scala:53)
      at 
org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:82)
      at 
org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:45)
      at 
org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parsePlan(ParseDriver.scala:53)
      at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:573)
      ... 48 elided
    ```
    
    - **After**
    ```
    scala> sql("CREATE TABLE partitioned_table (a STRING, b INT) PARTITIONED BY 
(c STRING, d STRING)")
    res0: org.apache.spark.sql.DataFrame = []
    
    scala> sql("ALTER TABLE partitioned_table ADD PARTITION (c='Us', d=1)")
    res1: org.apache.spark.sql.DataFrame = []
    
    scala> sql("DESC partitioned_table PARTITION (c='Us', d=1)").show(false)
    +-----------------------+---------+-------+
    |col_name               |data_type|comment|
    +-----------------------+---------+-------+
    |a                      |string   |null   |
    |b                      |int      |null   |
    |c                      |string   |null   |
    |d                      |string   |null   |
    |# Partition Information|         |       |
    |# col_name             |data_type|comment|
    |c                      |string   |null   |
    |d                      |string   |null   |
    +-----------------------+---------+-------+
    ```
    
    ## How was this patch tested?
    
    Pass the Jenkins tests with a new testcase.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-17612

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/15168.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #15168
    
----
commit 1396eb10db67382fbb99d0f28e39722ef6758d3b
Author: Dongjoon Hyun <dongj...@apache.org>
Date:   2016-09-20T19:57:47Z

    [SPARK-17612][SQL] Support `DESCRIBE table PARTITION` SQL syntax

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to