[feature](create table) show create table print storage medium (#29080)
This commit is contained in:
@ -3290,6 +3290,11 @@ public class Env {
|
||||
sb.append(olapTable.isInMemory()).append("\"");
|
||||
}
|
||||
|
||||
// storage medium
|
||||
sb.append(",\n\"").append(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM).append("\" = \"");
|
||||
sb.append(olapTable.getStorageMedium() == null ? "" : olapTable.getStorageMedium().name().toLowerCase());
|
||||
sb.append("\"");
|
||||
|
||||
// storage type
|
||||
sb.append(",\n\"").append(PropertyAnalyzer.PROPERTIES_STORAGE_FORMAT).append("\" = \"");
|
||||
sb.append(olapTable.getStorageFormat()).append("\"");
|
||||
|
||||
@ -1945,6 +1945,20 @@ public class OlapTable extends Table {
|
||||
return quorum;
|
||||
}
|
||||
|
||||
public void setStorageMedium(TStorageMedium medium) {
|
||||
TableProperty tableProperty = getOrCreatTableProperty();
|
||||
tableProperty.modifyTableProperties(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM,
|
||||
medium == null ? "" : medium.name());
|
||||
tableProperty.buildStorageMedium();
|
||||
}
|
||||
|
||||
public TStorageMedium getStorageMedium() {
|
||||
if (tableProperty != null) {
|
||||
return tableProperty.getStorageMedium();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setStoragePolicy(String storagePolicy) throws UserException {
|
||||
if (!Config.enable_storage_policy && !Strings.isNullOrEmpty(storagePolicy)) {
|
||||
throw new UserException("storage policy feature is disabled by default. "
|
||||
|
||||
@ -27,6 +27,7 @@ import org.apache.doris.persist.OperationType;
|
||||
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;
|
||||
@ -64,6 +65,8 @@ public class TableProperty implements Writable {
|
||||
private Boolean isBeingSynced = null;
|
||||
private BinlogConfig binlogConfig;
|
||||
|
||||
private TStorageMedium storageMedium = null;
|
||||
|
||||
/*
|
||||
* the default storage format of this table.
|
||||
* DEFAULT: depends on BE's config 'default_rowset_type'
|
||||
@ -126,6 +129,7 @@ public class TableProperty implements Writable {
|
||||
case OperationType.OP_MODIFY_IN_MEMORY:
|
||||
buildInMemory();
|
||||
buildMinLoadReplicaNum();
|
||||
buildStorageMedium();
|
||||
buildStoragePolicy();
|
||||
buildIsBeingSynced();
|
||||
buildCompactionPolicy();
|
||||
@ -303,6 +307,20 @@ public class TableProperty implements Writable {
|
||||
return minLoadReplicaNum;
|
||||
}
|
||||
|
||||
public TableProperty buildStorageMedium() {
|
||||
String storageMediumStr = properties.get(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM);
|
||||
if (Strings.isNullOrEmpty(storageMediumStr)) {
|
||||
storageMedium = null;
|
||||
} else {
|
||||
storageMedium = TStorageMedium.valueOf(storageMediumStr);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TStorageMedium getStorageMedium() {
|
||||
return storageMedium;
|
||||
}
|
||||
|
||||
public TableProperty buildStoragePolicy() {
|
||||
storagePolicy = properties.getOrDefault(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY, "");
|
||||
return this;
|
||||
@ -529,6 +547,7 @@ public class TableProperty implements Writable {
|
||||
.executeBuildDynamicProperty()
|
||||
.buildInMemory()
|
||||
.buildMinLoadReplicaNum()
|
||||
.buildStorageMedium()
|
||||
.buildStorageFormat()
|
||||
.buildDataSortInfo()
|
||||
.buildCompressionType()
|
||||
|
||||
@ -2313,7 +2313,8 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
DataProperty dataProperty = null;
|
||||
try {
|
||||
dataProperty = PropertyAnalyzer.analyzeDataProperty(stmt.getProperties(),
|
||||
new DataProperty(DataProperty.DEFAULT_STORAGE_MEDIUM));
|
||||
new DataProperty(DataProperty.DEFAULT_STORAGE_MEDIUM));
|
||||
olapTable.setStorageMedium(dataProperty.getStorageMedium());
|
||||
} catch (AnalysisException e) {
|
||||
throw new DdlException(e.getMessage());
|
||||
}
|
||||
@ -2494,8 +2495,8 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
} else if (partitionInfo.getType() == PartitionType.RANGE
|
||||
|| partitionInfo.getType() == PartitionType.LIST) {
|
||||
try {
|
||||
PropertyAnalyzer.analyzeDataProperty(stmt.getProperties(),
|
||||
new DataProperty(DataProperty.DEFAULT_STORAGE_MEDIUM));
|
||||
DataProperty dataProperty = PropertyAnalyzer.analyzeDataProperty(stmt.getProperties(),
|
||||
new DataProperty(DataProperty.DEFAULT_STORAGE_MEDIUM));
|
||||
Map<String, String> propertiesCheck = new HashMap<>(properties);
|
||||
propertiesCheck.entrySet().removeIf(entry -> entry.getKey().contains("dynamic_partition"));
|
||||
if (propertiesCheck != null && !propertiesCheck.isEmpty()) {
|
||||
@ -2504,6 +2505,7 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
}
|
||||
// just for remove entries in stmt.getProperties(),
|
||||
// and then check if there still has unknown properties
|
||||
olapTable.setStorageMedium(dataProperty.getStorageMedium());
|
||||
if (partitionInfo.getType() == PartitionType.RANGE) {
|
||||
DynamicPartitionUtil.checkAndSetDynamicPartitionProperty(olapTable, properties, db);
|
||||
} else if (partitionInfo.getType() == PartitionType.LIST) {
|
||||
|
||||
Reference in New Issue
Block a user