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

Implement support for DEFAULT values for columns in tables

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.0
    • 3.4.0
    • SQL

    Description

      This story tracks the implementation of DEFAULT values for columns in tables.

      CREATE TABLE and ALTER TABLE invocations will support setting column default values for future operations. Following INSERT, UPDATE, MERGE statements may then reference the value using the DEFAULT keyword as needed.

      Examples:

      CREATE TABLE T(a INT, b INT NOT NULL);
      
      -- The default default is NULL
      INSERT INTO T VALUES (DEFAULT, 0);
      INSERT INTO T(b)  VALUES (1);
      SELECT * FROM T;
      (NULL, 0)
      (NULL, 1)
      
      -- Adding a default to a table with rows, sets the values for the
      -- existing rows (exist default) and new rows (current default).
      ALTER TABLE T ADD COLUMN c INT DEFAULT 5;
      INSERT INTO T VALUES (1, 2, DEFAULT);
      SELECT * FROM T;
      (NULL, 0, 5)
      (NULL, 1, 5)
      (1, 2, 5) 

      Attachments

        Issue Links

          Activity

            People

              dtenedor Daniel
              dtenedor Daniel
              Gengliang Wang Gengliang Wang
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: