diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java index 7addc8053f29b1..b52d09e42c5223 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java @@ -1574,6 +1574,13 @@ public void addPartition(Database db, String tableName, AddPartitionClause addPa if (!properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY)) { properties.put(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY, olapTable.getStoragePolicy()); } + if (!properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM)) { + TStorageMedium tableStorageMedium = olapTable.getStorageMedium(); + if (tableStorageMedium != null) { + properties.put(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM, + tableStorageMedium.name().toLowerCase()); + } + } singlePartitionDesc.analyze(partitionInfo.getPartitionColumns().size(), properties); partitionInfo.createAndCheckPartitionItem(singlePartitionDesc, isTempPartition); diff --git a/regression-test/pipeline/p0/conf/be.conf b/regression-test/pipeline/p0/conf/be.conf index 67605a5bdd9a89..d2f4910aa2af24 100644 --- a/regression-test/pipeline/p0/conf/be.conf +++ b/regression-test/pipeline/p0/conf/be.conf @@ -47,7 +47,7 @@ max_garbage_sweep_interval=180 log_buffer_level = -1 enable_stream_load_record = true -storage_root_path=/mnt/ssd01/cluster_storage/doris.SSD/P0/cluster1 +storage_root_path=/mnt/ssd01/cluster_storage/doris.SSD/P0/cluster1;/mnt/ssd01/cluster_storage/doris.SSD disable_auto_compaction=true priority_networks=172.19.0.0/24 enable_fuzzy_mode=true diff --git a/regression-test/suites/mtmv_p0/test_storage_medium_mtmv.groovy b/regression-test/suites/mtmv_p0/test_storage_medium_mtmv.groovy new file mode 100644 index 00000000000000..947ee72b08d302 --- /dev/null +++ b/regression-test/suites/mtmv_p0/test_storage_medium_mtmv.groovy @@ -0,0 +1,80 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import org.junit.Assert; + +suite("test_storage_medium_mtmv","mtmv") { + String suiteName = "test_storage_medium_mtmv" + String tableName = "${suiteName}_table" + String mvName = "${suiteName}_mv" + sql """drop table if exists `${tableName}`""" + sql """drop materialized view if exists ${mvName};""" + + sql """ + CREATE TABLE ${tableName} + ( + k2 TINYINT, + k3 INT not null + ) + COMMENT "my first table" + PARTITION BY LIST(`k3`) + ( + PARTITION `p1` VALUES IN ('1'), + PARTITION `p2` VALUES IN ('2'), + PARTITION `p3` VALUES IN ('3') + ) + DISTRIBUTED BY HASH(k2) BUCKETS 2 + PROPERTIES ( + "replication_num" = "1" + ); + """ + sql """ + CREATE MATERIALIZED VIEW ${mvName} + BUILD DEFERRED REFRESH AUTO ON MANUAL + partition by(`k3`) + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ( + 'replication_num' = '1', + 'storage_medium' = 'SSD' + ) + AS + SELECT * from ${tableName}; + """ + + // test init + def res = sql """show partitions from ${mvName}""" + logger.info("res: " + res.toString()) + assertTrue(res.toString().contains("SSD")) + assertFalse(res.toString().contains("HDD")) + + sql """ + insert into ${tableName} values(1,1),(2,2),(3,3); + """ + sql """ + REFRESH MATERIALIZED VIEW ${mvName} AUTO + """ + waitingMTMVTaskFinishedByMvName(mvName) + + // test after refresh + res = sql """show partitions from ${mvName}""" + logger.info("res: " + res.toString()) + assertTrue(res.toString().contains("SSD")) + assertFalse(res.toString().contains("HDD")) + + sql """drop table if exists `${tableName}`""" + sql """drop materialized view if exists ${mvName};""" +}