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 f8854b6862..3b5c64b7ff 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 81ab5f8d20..a6e4bfcff2 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 properties) { + if (properties != null && properties.containsKey(PROPERTIES_STORAGE_POLICY)) { + return true; + } + return false; + } + // analyze property like : "type" = "xxx"; public static String analyzeType(Map 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 fcf8485eaf..b3ea5c7c8d 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"="")