This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 8c2713b2e5a [fix](alter) alter partition without storage_policy
property will also cancel storage_policy (#51662) (#51910)
8c2713b2e5a is described below
commit 8c2713b2e5af32404b13448782ccd606da58bb97
Author: camby <[email protected]>
AuthorDate: Fri Jun 20 12:18:36 2025 +0800
[fix](alter) alter partition without storage_policy property will also
cancel storage_policy (#51662) (#51910)
### What problem does this PR solve?
pick #51662 to branch-2.1
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
---
fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java | 4 +++-
.../java/org/apache/doris/common/util/PropertyAnalyzer.java | 7 +++++++
.../test_show_storage_policy_using.groovy | 11 +++++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
index f8854b6862e..3b5c64b7ff2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
@@ -860,7 +860,9 @@ public class Alter {
// check currentStoragePolicy resource exist.
Env.getCurrentEnv().getPolicyMgr().checkStoragePolicyExist(currentStoragePolicy);
partitionInfo.setStoragePolicy(partition.getId(),
currentStoragePolicy);
- } else {
+ } else if (PropertyAnalyzer.hasStoragePolicy(properties)) {
+ // only set "storage_policy" = "", means cancel storage policy
+ // if current partition is already in remote storage
if (partition.getRemoteDataSize() > 0) {
throw new AnalysisException(
"Cannot cancel storage policy for partition which is
already on code storage.");
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
index 81ab5f8d206..a6e4bfcff26 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
@@ -1025,6 +1025,13 @@ public class PropertyAnalyzer {
return storagePolicy;
}
+ public static boolean hasStoragePolicy(Map<String, String> properties) {
+ if (properties != null &&
properties.containsKey(PROPERTIES_STORAGE_POLICY)) {
+ return true;
+ }
+ return false;
+ }
+
// analyze property like : "type" = "xxx";
public static String analyzeType(Map<String, String> properties) throws
AnalysisException {
String type = null;
diff --git
a/regression-test/suites/cold_heat_separation_p2/test_show_storage_policy_using.groovy
b/regression-test/suites/cold_heat_separation_p2/test_show_storage_policy_using.groovy
index fcf8485eaf9..b3ea5c7c8de 100644
---
a/regression-test/suites/cold_heat_separation_p2/test_show_storage_policy_using.groovy
+++
b/regression-test/suites/cold_heat_separation_p2/test_show_storage_policy_using.groovy
@@ -156,6 +156,17 @@ suite("test_show_storage_policy_using") {
"""
assertTrue(show_result.size() >= 4)
+ // alter other property, will not cancel storage_policy
+ sql """ ALTER STORAGE POLICY ${policy_name} PROPERTIES("cooldown_ttl" =
"1"); """
+ sql """
+ ALTER TABLE partition_with_multiple_storage_policy MODIFY PARTITION
(`p201701`) SET ("replication_num"="1")
+ """
+ show_result = sql """
+ show storage policy using for ${policy_name}
+ """
+ assertEquals(show_result.size(), 2)
+ sql """ ALTER STORAGE POLICY ${policy_name} PROPERTIES("cooldown_ttl" =
"300"); """
+
// test cancel a partition's storage policy
sql """
ALTER TABLE partition_with_multiple_storage_policy MODIFY PARTITION
(`p201701`) SET ("storage_policy"="")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]