This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new f2eafe5ba7d [enhance]support alter table storage_medium (#50198)
f2eafe5ba7d is described below

commit f2eafe5ba7df99a0fc8be847dda9d770d6ab2f61
Author: kkop <[email protected]>
AuthorDate: Tue May 6 20:54:08 2025 +0800

    [enhance]support alter table storage_medium (#50198)
    
    ### What problem does this PR solve?
    
    Issue Number: close #49744
---
 .../main/java/org/apache/doris/alter/SchemaChangeHandler.java    | 8 +++++++-
 fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java       | 1 +
 .../trees/plans/commands/info/ModifyTablePropertiesOp.java       | 3 +++
 regression-test/suites/alter_p2/test_alter_table_property.groovy | 9 +++++++++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java 
b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
index a235fd76182..79840ce92ab 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
@@ -2033,6 +2033,9 @@ public class SchemaChangeHandler extends AlterHandler {
                             rowColumn.setUniqueId(maxColUniqueId + 1);
                             
indexSchemaMap.get(olapTable.getBaseIndexId()).add(rowColumn);
                         }
+                    } else if 
(properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM)) {
+                        Env.getCurrentEnv().modifyTableProperties(db, 
olapTable, properties);
+                        return;
                     }
                 }
 
@@ -2338,6 +2341,7 @@ public class SchemaChangeHandler extends AlterHandler {
                 
add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_EMPTY_ROWSETS_THRESHOLD);
                 
add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_LEVEL_THRESHOLD);
                 add(PropertyAnalyzer.PROPERTIES_AUTO_ANALYZE_POLICY);
+                add(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM);
             }
         };
         List<String> notAllowedProps = properties.keySet().stream().filter(s 
-> !allowedProps.contains(s))
@@ -2418,6 +2422,7 @@ public class SchemaChangeHandler extends AlterHandler {
                         
.get(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_LEVEL_THRESHOLD)));
         }
 
+
         if (isInMemory < 0 && storagePolicyId < 0 && compactionPolicy == null 
&& timeSeriesCompactionConfig.isEmpty()
                 && 
!properties.containsKey(PropertyAnalyzer.PROPERTIES_IS_BEING_SYNCED)
                 && 
!properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE)
@@ -2426,7 +2431,8 @@ public class SchemaChangeHandler extends AlterHandler {
                 && 
!properties.containsKey(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_INTERVAL_MS)
                 && 
!properties.containsKey(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_DATA_BYTES)
                 && 
!properties.containsKey(PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD)
-                && 
!properties.containsKey(PropertyAnalyzer.PROPERTIES_AUTO_ANALYZE_POLICY)) {
+                && 
!properties.containsKey(PropertyAnalyzer.PROPERTIES_AUTO_ANALYZE_POLICY)
+                && 
!properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM)) {
             LOG.info("Properties already up-to-date");
             return;
         }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 4ec9c37798e..b9617f62d21 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -5634,6 +5634,7 @@ public class Env {
         tableProperty.buildInMemory()
                 .buildMinLoadReplicaNum()
                 .buildStoragePolicy()
+                .buildStorageMedium()
                 .buildIsBeingSynced()
                 .buildCompactionPolicy()
                 .buildTimeSeriesCompactionGoalSizeMbytes()
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ModifyTablePropertiesOp.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ModifyTablePropertiesOp.java
index bb2ea34bb63..931aef61941 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ModifyTablePropertiesOp.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ModifyTablePropertiesOp.java
@@ -371,6 +371,9 @@ public class ModifyTablePropertiesOp extends AlterTableOp {
             throw new AnalysisException("You can not modify property 
'enable_unique_key_skip_bitmap_column'.");
         } else if 
(properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_PAGE_SIZE)) {
             throw new AnalysisException("You can not modify 
storage_page_size");
+        } else if 
(properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM)) {
+            this.needTableStable = false;
+            this.opType = AlterOpType.MODIFY_TABLE_PROPERTY_SYNC;
         } else {
             throw new AnalysisException("Unknown table property: " + 
properties.keySet());
         }
diff --git a/regression-test/suites/alter_p2/test_alter_table_property.groovy 
b/regression-test/suites/alter_p2/test_alter_table_property.groovy
index 5ad017f276c..c50f5426e41 100644
--- a/regression-test/suites/alter_p2/test_alter_table_property.groovy
+++ b/regression-test/suites/alter_p2/test_alter_table_property.groovy
@@ -79,6 +79,15 @@ suite ("test_alter_table_property") {
     assertEquals(2, queryReplicaCount("p1"))
     assertEquals(replication_num, queryReplicaCount("p2"))
 
+    sql """ ALTER TABLE ${tableName} SET("storage_medium"="SSD") """
+
+    def result = sql_return_maparray """
+    show create table ${tableName}
+    """
+    logger.info(${result[0]})
+    def createTableStr = result[0]['Create Table']
+    assertTrue(createTableStr.contains("\"storage_medium\" = \"ssd\""))
+
     sql "DROP TABLE ${tableName}"
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to