GitHub user dongjoon-hyun opened a pull request:

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

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

    ## What changes were proposed in this pull request?
    
    This is a backport of SPARK-17612. This 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
    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
    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
    ```
    
    - **After**
    ```scala
    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   |
    +-----------------------+---------+-------+
    
    scala> sql("DESC EXTENDED partitioned_table PARTITION (c='Us', 
d=1)").show(100,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   |
    |                                                                           
                                                                                
                                                                                
                                                                                
                                                                                
                                                                        |       
  |       |
    |Detailed Partition Information CatalogPartition(
            Partition Values: [Us, 1]
            Storage(Location: 
file:/Users/dhyun/SPARK-17612-DESC-PARTITION/spark-warehouse/partitioned_table/c=Us/d=1,
 InputFormat: org.apache.hadoop.mapred.TextInputFormat, OutputFormat: 
org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, Serde: 
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Properties: 
[serialization.format=1])
            Partition Parameters:{transient_lastDdlTime=1475001066})|         | 
      |
    
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+-------+
    
    
    scala> sql("DESC FORMATTED partitioned_table PARTITION (c='Us', 
d=1)").show(100,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   |
    |                                |                                          
                                             |       |
    |# Detailed Partition Information|                                          
                                             |       |
    |Partition Value:                |[Us, 1]                                   
                                             |       |
    |Database:                       |default                                   
                                             |       |
    |Table:                          |partitioned_table                         
                                             |       |
    |Location:                       
|file:/Users/dhyun/SPARK-17612-DESC-PARTITION/spark-warehouse/partitioned_table/c=Us/d=1|
       |
    |Partition Parameters:           |                                          
                                             |       |
    |  transient_lastDdlTime         |1475001066                                
                                             |       |
    |                                |                                          
                                             |       |
    |# Storage Information           |                                          
                                             |       |
    |SerDe Library:                  
|org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe                             
        |       |
    |InputFormat:                    |org.apache.hadoop.mapred.TextInputFormat  
                                             |       |
    |OutputFormat:                   
|org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat                     
        |       |
    |Compressed:                     |No                                        
                                             |       |
    |Storage Desc Parameters:        |                                          
                                             |       |
    |  serialization.format          |1                                         
                                             |       |
    
+--------------------------------+---------------------------------------------------------------------------------------+-------+
    ```
    
    ## 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-BACK

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

    https://github.com/apache/spark/pull/15351.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 #15351
    
----
commit e5f7ced64ef23c82103bad9e86deb993e9eaed97
Author: Dongjoon Hyun <[email protected]>
Date:   2016-10-04T22:30:03Z

    [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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to