Skip to content

Comments

[SPARK-38939][SQL] Support DROP [IF EXISTS] COLUMN syntax#36249

Closed
jackierwzhang wants to merge 3 commits intoapache:masterfrom
jackierwzhang:SPARK-38939-drop-if-exists
Closed

[SPARK-38939][SQL] Support DROP [IF EXISTS] COLUMN syntax#36249
jackierwzhang wants to merge 3 commits intoapache:masterfrom
jackierwzhang:SPARK-38939-drop-if-exists

Conversation

@jackierwzhang
Copy link
Contributor

What changes were proposed in this pull request?

This PR introduces the following:

  • Parser changes to have an IF EXISTS syntax for DROP COLUMN.
  • Logic to silence the errors within parser and analyzer when encountering missing columns while using IF EXISTS
  • Ensure only resolving and dropping existing columns inside table schema

Why are the changes needed?

Currently ALTER TABLE ... DROP COLUMN(s) ... syntax will always throw error if the column doesn't exist. This PR would like to provide an (IF EXISTS) syntax to provide better user experience for downstream handlers (such as Delta with incoming column dropping support) that support it, and make consistent with some other DMLs such as DROP TABLE (IF EXISTS).

Does this PR introduce any user-facing change?

User may now specify ALTER TABLE xxx DROP IF EXISTS COLUMN(S) a, a.b, c.d.

How was this patch tested?

Modified existing unit tests and new unit tests.

@github-actions github-actions bot added the SQL label Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant