Skip to content

fix(query): support IF NOT EXISTS for ALTER TABLE ADD COLUMN#19615

Merged
b41sh merged 10 commits intodatabendlabs:mainfrom
sundy-li:issue-19611-20260325-1030
Apr 5, 2026
Merged

fix(query): support IF NOT EXISTS for ALTER TABLE ADD COLUMN#19615
b41sh merged 10 commits intodatabendlabs:mainfrom
sundy-li:issue-19611-20260325-1030

Conversation

@sundy-li
Copy link
Copy Markdown
Member

@sundy-li sundy-li commented Mar 25, 2026

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  • add parser support for ALTER TABLE ... ADD COLUMN IF NOT EXISTS
  • make duplicate add-column requests a no-op when IF NOT EXISTS is present
  • add Rust and SQL regressions for the new idempotent DDL behavior

Changes

  1. Extended the ALTER TABLE add-column AST, display formatting, and parser grammar with an if_not_exists flag.
  2. Threaded the new flag through the add-column plan in the SQL binder.
  3. Short-circuited binder/interpreter execution when the target column already exists and IF NOT EXISTS is specified.
  4. Added AST parser coverage, a fuse storage integration test, and a sqllogictest regression.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Pair with the reviewer to explain why

Validation commands:

cargo test -p databend-common-ast --test it parser::test_statement -- --exact
cargo test -p databend-query --test it add_column_if_not_exists -- --nocapture
cargo clippy -p databend-common-sql --lib -- -D warnings
cargo clippy -p databend-common-ast --test it -- -D warnings

Type of change

  • Bug fix

Fixes #19611


This change is Reviewable

@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Mar 25, 2026
@sundy-li sundy-li added the agent-reviewable Ready for agent review label Mar 25, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fffb788166

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@sundy-li sundy-li added agent-changed Changed by agent agent-approved Approved by agent and removed agent-reviewable Ready for agent review agent-changed Changed by agent labels Mar 25, 2026
@sundy-li
Copy link
Copy Markdown
Member Author

ci check is failed, please fix the check

@sundy-li sundy-li added agent-changed Changed by agent and removed agent-approved Approved by agent labels Mar 26, 2026
@sundy-li sundy-li added agent-reviewable Ready for agent review and removed agent-changed Changed by agent labels Mar 26, 2026
@sundy-li sundy-li added agent-approved Approved by agent agent-changed Changed by agent and removed agent-reviewable Ready for agent review agent-approved Approved by agent labels Mar 26, 2026
@sundy-li sundy-li added agent-reviewable Ready for agent review and removed agent-changed Changed by agent labels Mar 27, 2026
@sundy-li sundy-li added agent-approved Approved by agent agent-changed Changed by agent and removed agent-reviewable Ready for agent review agent-approved Approved by agent labels Mar 27, 2026
@sundy-li sundy-li removed the agent-changed Changed by agent label Mar 29, 2026
@sundy-li sundy-li added agent-reviewable Ready for agent review agent-approved Approved by agent and removed agent-reviewable Ready for agent review labels Mar 29, 2026
@b41sh b41sh enabled auto-merge April 5, 2026 01:01
@b41sh b41sh added this pull request to the merge queue Apr 5, 2026
@b41sh b41sh removed this pull request from the merge queue due to a manual request Apr 5, 2026
@b41sh b41sh added this pull request to the merge queue Apr 5, 2026
Merged via the queue into databendlabs:main with commit 15a82a5 Apr 5, 2026
176 of 178 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-approved Approved by agent pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ALTER TABLE ADD COLUMN should support IF NOT EXISTS

2 participants