Skip to content

Conversation

@Dan-J-D
Copy link
Contributor

@Dan-J-D Dan-J-D commented Dec 12, 2025

Why I'm doing:

According to this, the syntax is

ALTER STORAGE VOLUME [ IF EXISTS ] <storage_volume_name>
{ COMMENT = '<comment_string>'
| SET ("key" = "value"[,...]) }

But doesn't support IF EXISTS.

What I'm doing:

Fixes syntax to add IF EXISTS.

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.0
    • 3.5
    • 3.4
    • 3.3

Note

Implements IF EXISTS for ALTER STORAGE VOLUME and aligns not-found behavior across layers.

  • Grammar: allow ALTER STORAGE VOLUME (IF EXISTS)? ...; AstBuilder passes the flag; AlterStorageVolumeStmt stores ifExists.
  • Executor: visitAlterStorageVolumeStatement ignores MetaNotFoundException when IF EXISTS is set.
  • Manager: StorageVolumeMgr.updateStorageVolume(...) now throws MetaNotFoundException if the volume is missing; signature updated and immutable-property checks preserved.
  • Tests: updated unit tests to expect MetaNotFoundException; added SQL tests for ALTER STORAGE VOLUME IF EXISTS behavior.

Written by Cursor Bugbot for commit 487193f. This will update automatically on new commits. Configure here.

@Dan-J-D Dan-J-D requested a review from a team as a code owner December 12, 2025 23:48
@mergify
Copy link
Contributor

mergify bot commented Dec 12, 2025

🧪 CI Insights

Here's what we observed from your CI run for 38c975c.

🟢 All jobs passed!

But CI Insights is watching 👀

@Dan-J-D Dan-J-D changed the title fix: ALTER STORAGE VOLUME [IF EXISTS] [BugFix] fixed ALTER STORAGE VOLUME [IF EXISTS] Dec 12, 2025
@Dan-J-D Dan-J-D force-pushed the fix-alter-storage-volume branch from 089a517 to c2c97f2 Compare December 12, 2025 23:56
@alvin-celerdata
Copy link
Contributor

@cursor review

@Dan-J-D Dan-J-D force-pushed the fix-alter-storage-volume branch from ac052e4 to 38c975c Compare December 13, 2025 01:30
@alvin-celerdata
Copy link
Contributor

@cursor review

@Dan-J-D Dan-J-D force-pushed the fix-alter-storage-volume branch from e2f2d13 to a5ac114 Compare December 13, 2025 15:04
@alvin-celerdata
Copy link
Contributor

@cursor review

@alvin-celerdata
Copy link
Contributor

@cursor review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for the IF EXISTS clause to the ALTER STORAGE VOLUME statement, aligning the implementation with the documented SQL syntax. The change propagates the ifExists flag through the AST and updates the storage volume manager to throw MetaNotFoundException instead of using precondition checks when a volume doesn't exist.

Key Changes:

  • Added IF EXISTS syntax support to the SQL grammar for ALTER STORAGE VOLUME
  • Threaded ifExists boolean flag through AlterStorageVolumeStmt and related code
  • Changed StorageVolumeMgr.updateStorageVolume methods to throw MetaNotFoundException instead of failing precondition checks

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
fe/fe-grammar/src/main/antlr/com/starrocks/grammar/StarRocks.g4 Added optional IF EXISTS clause to alterStorageVolumeStatement grammar rule
fe/fe-parser/src/main/java/com/starrocks/sql/ast/AlterStorageVolumeStmt.java Added ifExists field, updated constructor signature, and added isSetIfExists() accessor method
fe/fe-core/src/main/java/com/starrocks/sql/parser/AstBuilder.java Updated to parse IF EXISTS and pass it to AlterStorageVolumeStmt constructor
fe/fe-core/src/main/java/com/starrocks/server/StorageVolumeMgr.java Changed all updateStorageVolume overloads to throw MetaNotFoundException; replaced precondition check with explicit exception throw
fe/fe-core/src/main/java/com/starrocks/qe/DDLStmtExecutor.java Reformatted lambda for alter storage volume execution (added braces)
fe/fe-core/src/test/java/com/starrocks/qe/RedirectStatusTest.java Updated test to use new AlterStorageVolumeStmt constructor with ifExists parameter
fe/fe-core/src/test/java/com/starrocks/server/SharedDataStorageVolumeMgrTest.java Added MetaNotFoundException to method signature and fixed variable naming consistency

@alvin-celerdata
Copy link
Contributor

@cursor review

@Dan-J-D
Copy link
Contributor Author

Dan-J-D commented Dec 18, 2025

Any update?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

fe/fe-parser/src/main/java/com/starrocks/sql/ast/AlterStorageVolumeStmt.java:60

  • Missing toSql() method implementation. Similar storage volume statements like DropStorageVolumeStmt implement toSql() to properly represent the IF EXISTS clause in the SQL string. AlterStorageVolumeStmt should also implement toSql() to include "IF EXISTS" when the ifExists flag is true, ensuring consistency across storage volume statements and proper SQL representation for logging and debugging purposes.
    @Override
    public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
        return visitor.visitAlterStorageVolumeStatement(this, context);
    }

Copy link
Contributor

@kevincai kevincai left a comment

Choose a reason for hiding this comment

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

new test case shall be added to cover this new added IF EXISTS check. either in unit test or in sql-test

@Dan-J-D Dan-J-D force-pushed the fix-alter-storage-volume branch from a4c47a7 to 797c309 Compare December 21, 2025 21:06
@alvin-celerdata
Copy link
Contributor

@mergify rebase

@mergify
Copy link
Contributor

mergify bot commented Dec 26, 2025

rebase

✅ Branch has been successfully rebased

@alvin-celerdata alvin-celerdata force-pushed the fix-alter-storage-volume branch from 929645e to 487193f Compare December 26, 2025 22:02
@alvin-celerdata
Copy link
Contributor

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!

@sonarqubecloud
Copy link

@github-actions
Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions
Copy link

[FE Incremental Coverage Report]

fail : 5 / 9 (55.56%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/server/StorageVolumeMgr.java 1 2 50.00% [186]
🔵 com/starrocks/qe/DDLStmtExecutor.java 4 7 57.14% [1150, 1151, 1152]

@github-actions
Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@kevincai kevincai enabled auto-merge (squash) December 27, 2025 10:42
@alvin-celerdata alvin-celerdata merged commit bf73f06 into StarRocks:main Dec 27, 2025
83 of 85 checks passed
@github-actions
Copy link

@Mergifyio backport branch-4.0

@github-actions github-actions bot removed the 4.0 label Dec 27, 2025
@mergify
Copy link
Contributor

mergify bot commented Dec 27, 2025

backport branch-4.0

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Dec 27, 2025
## Why I'm doing:
According to [this](https://docs.starrocks.io/docs/sql-reference/sql-statements/cluster-management/storage_volume/ALTER_STORAGE_VOLUME/), the syntax is
```sql
ALTER STORAGE VOLUME [ IF EXISTS ] <storage_volume_name>
{ COMMENT = '<comment_string>'
| SET ("key" = "value"[,...]) }
```

But doesn't support `IF EXISTS`.

## What I'm doing:

Fixes syntax to add `IF EXISTS`.

Signed-off-by: Dan-J-D <[email protected]>
Co-authored-by: Kevin Cai <[email protected]>
(cherry picked from commit bf73f06)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/sql/ast/AlterStorageVolumeStmt.java
#	fe/fe-core/src/test/java/com/starrocks/qe/RedirectStatusTest.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants