Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-22934

Make optional clauses order insensitive for CREATE TABLE SQL statement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.2.1
    • 2.3.0
    • SQL
    • None

    Description

      Each time, when I write a complex Create Table statement, I have to open the .g4 file to find the EXACT order of clauses in CREATE TABLE statement. When the order is not right, I will get A strange confusing error message generated from ALTR4.

      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, ...)]
      

      Attachments

        Activity

          People

            smilegator Xiao Li
            smilegator Xiao Li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: