GitHub user gatorsmile opened a pull request:

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

    [SPARK-22934] [SQL] Make optional clauses order insensitive for CREATE 
TABLE SQL statement

    ## What changes were proposed in this pull request?
    Currently, our CREATE TABLE syntax require the EXACT order of clauses. It 
is pretty hard to remember the exact order. Thus, this PR is to make optional 
clauses order insensitive for `CREATE TABLE` SQL statement.
    
    ```
    CREATE [TEMPORARY] TABLE [IF NOT EXISTS] [db_name.]table_name
        [(col_name1 col_type1 [COMMENT col_comment1], ...)]
        USING datasource
        [OPTIONS (key1=val1, key2=val2, ...)]
        [PARTITIONED BY (col_name1, col_name2, ...)]
        [CLUSTERED BY (col_name3, col_name4, ...) INTO num_buckets BUCKETS]
        [LOCATION path]
        [COMMENT table_comment]
        [TBLPROPERTIES (key1=val1, key2=val2, ...)]
        [AS select_statement]
    ```
    
    The proposal is to make the following clauses order insensitive. 
    ```
        [OPTIONS (key1=val1, key2=val2, ...)]
        [PARTITIONED BY (col_name1, col_name2, ...)]
        [CLUSTERED BY (col_name3, col_name4, ...) INTO num_buckets BUCKETS]
        [LOCATION path]
        [COMMENT table_comment]
        [TBLPROPERTIES (key1=val1, key2=val2, ...)]
    ```
    
    The same idea is also applicable to Create Hive Table. 
    ```
    CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name
        [(col_name1[:] col_type1 [COMMENT col_comment1], ...)]
        [COMMENT table_comment]
        [PARTITIONED BY (col_name2[:] col_type2 [COMMENT col_comment2], ...)]
        [ROW FORMAT row_format]
        [STORED AS file_format]
        [LOCATION path]
        [TBLPROPERTIES (key1=val1, key2=val2, ...)]
        [AS select_statement]
    ```
    
    The proposal is to make the following clauses order insensitive. 
    ```
        [COMMENT table_comment]
        [PARTITIONED BY (col_name2[:] col_type2 [COMMENT col_comment2], ...)]
        [ROW FORMAT row_format]
        [STORED AS file_format]
        [LOCATION path]
        [TBLPROPERTIES (key1=val1, key2=val2, ...)]
    ```
    
    ## How was this patch tested?
    Added test cases

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

    $ git pull https://github.com/gatorsmile/spark createDataSourceTableDDL

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

    https://github.com/apache/spark/pull/20133.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 #20133
    
----
commit 8ae8f1832a62caf10a62511f339402c0d94f89ea
Author: gatorsmile <gatorsmile@...>
Date:   2018-01-01T07:03:01Z

    fix

----


---

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

Reply via email to