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

Add SQL syntax in create/replace table to create an identity column

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.0.0
    • 4.0.0
    • SQL

    Description

      Add SQL support for creating identity columns. Identity Column syntax should be flexible such that users can specify 

      • whether identity values are always generated by the system
      • (optionally) the starting value of the column 
      • (optionally) the increment/step of the column

      The SQL syntax support should also allow flexible ordering of the increment and starting values, as both variants are used in the wild by other systems (e.g. PostgreSQL Oracle). That is, we should allow both

      START WITH <start> INCREMENT BY <step>

      and

      INCREMENT BY <step> START WITH <start>

      .

      For example, we should be able to define

      CREATE TABLE default.example (
        id LONG GENERATED ALWAYS AS IDENTITY,
        id2 LONG GENERATED BY DEFAULT START WITH 0 INCREMENT BY -10,
        id3 LONG GENERATED ALWAYS AS IDENTITY INCREMENT BY 2 START WITH -8,
        value LONG
      )
      

      This will enable defining identity columns in Spark SQL for data sources that support it. 

      Attachments

        Issue Links

          Activity

            People

              c27kwan Carmen Kwan
              c27kwan Carmen Kwan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: