Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-1614

ALTER TABLE ADD IF NOT EXISTS doesn't work as expected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.15.0, 5.1.0
    • None

    Description

      On an existing table table, executing "ALTER TABLE ADD IF NOT EXISTS
      thisColAlreadyExists varchar, thisColDoesNotExist varchar", then
      nothing will be changed in the table because thisColAlreadyExists
      already exists.

      Omitting the already-existing column from the statement, all new columns
      do get created.

      The general expectation would be that when you use ADD IF NOT EXISTS, all
      non-existent columns will be added, and all existing columns in the
      statement will just be ignored. There is already an integration test
      (AlterTableIT#testAddVarCols) that actually demonstrates the current
      behavior, although this is probably not correct.

      As pointed out in the related mailing list thread [1], ALTER TABLE DROP COLUMN likely suffers from the same issue.

      1. http://s.apache.org/LMT

      Attachments

        1. PHOENIX-1614.patch
          44 kB
          Toshihiro Suzuki
        2. PHOENIX-1614-v2.patch
          45 kB
          Toshihiro Suzuki
        3. PHOENIX-1614-v3.patch
          46 kB
          Toshihiro Suzuki
        4. PHOENIX-1614-v4.patch
          9 kB
          Toshihiro Suzuki
        5. PHOENIX-1614-v5.patch
          9 kB
          Toshihiro Suzuki

        Issue Links

          Activity

            People

              brfrn169 Toshihiro Suzuki
              gabriel.reid Gabriel Reid
              Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: