From edf88eac438ad2239aadace9d9bcd6d70d92602b Mon Sep 17 00:00:00 2001 From: zhengshengjun Date: Sun, 29 Jan 2023 15:58:32 +0800 Subject: [PATCH] [fix](meta) Persist storage_medium property for OlapTable and allow partition to inherit this table property --- .../java/org/apache/doris/catalog/OlapTable.java | 3 +++ .../org/apache/doris/catalog/TableProperty.java | 11 +++++++++++ .../apache/doris/datasource/InternalCatalog.java | 14 ++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java index b2333e019a43a4..0da99c8efca3af 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java @@ -2010,4 +2010,7 @@ public Set getPartitionKeys() { return idToPartition.keySet(); } + public TStorageMedium getStorageMedium() { + return tableProperty.getStorageMedium(); + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java index 6615e6598276db..cf1904c8d6e52d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java @@ -27,10 +27,12 @@ import org.apache.doris.persist.gson.GsonUtils; import org.apache.doris.thrift.TCompressionType; import org.apache.doris.thrift.TStorageFormat; +import org.apache.doris.thrift.TStorageMedium; import com.google.common.base.Strings; import com.google.common.collect.Maps; import com.google.gson.annotations.SerializedName; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -303,6 +305,15 @@ public String getSequenceMapCol() { + PropertyAnalyzer.PROPERTIES_SEQUENCE_COL); } + public TStorageMedium getStorageMedium() { + String s = properties.get(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM); + if (StringUtils.isNotEmpty(s)) { + return TStorageMedium.valueOf(s); + } else { + return DataProperty.DEFAULT_STORAGE_MEDIUM; + } + } + public void buildReplicaAllocation() { try { // Must copy the properties because "analyzeReplicaAllocation" will remove the property 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 4aa4ce71c30278..f554ac3a9e07bd 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 @@ -1356,6 +1356,11 @@ public void addPartition(Database db, String tableName, AddPartitionClause addPa olapTable.storeRowColumn().toString()); } + if (!properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM)) { + properties.put(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM, + olapTable.getStorageMedium().name()); + } + singlePartitionDesc.analyze(partitionInfo.getPartitionColumns().size(), properties); partitionInfo.createAndCheckPartitionItem(singlePartitionDesc, isTempPartition); @@ -2131,10 +2136,11 @@ private void createOlapTable(Database db, CreateTableStmt stmt) throws UserExcep } else if (partitionInfo.getType() == PartitionType.RANGE || partitionInfo.getType() == PartitionType.LIST) { try { - // just for remove entries in stmt.getProperties(), - // and then check if there still has unknown properties - PropertyAnalyzer.analyzeDataProperty(stmt.getProperties(), - new DataProperty(DataProperty.DEFAULT_STORAGE_MEDIUM)); + // remove entries in stmt.getProperties, and then check if there still has unknown properties + DataProperty dataProperty = PropertyAnalyzer.analyzeDataProperty(stmt.getProperties(), + new DataProperty(DataProperty.DEFAULT_STORAGE_MEDIUM)); + olapTable.getTableProperty().modifyTableProperties(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM, + dataProperty.getStorageMedium().name()); if (partitionInfo.getType() == PartitionType.RANGE) { DynamicPartitionUtil.checkAndSetDynamicPartitionProperty(olapTable, properties, db);