[feature](cooldown) Forbid storage policy for MoW tables (#17148)
* disable setting storage policy on MoW table * fix error in regression test * make the name of test table unique * use Strings.isNullOrEmpty to replace equals * fix error in if statement
This commit is contained in:
@ -1917,8 +1917,10 @@ public class SchemaChangeHandler extends AlterHandler {
|
||||
throws UserException {
|
||||
List<Partition> partitions = Lists.newArrayList();
|
||||
OlapTable olapTable = (OlapTable) db.getTableOrMetaException(tableName, Table.TableType.OLAP);
|
||||
boolean enableUniqueKeyMergeOnWrite = false;
|
||||
olapTable.readLock();
|
||||
try {
|
||||
enableUniqueKeyMergeOnWrite = olapTable.getEnableUniqueKeyMergeOnWrite();
|
||||
partitions.addAll(olapTable.getPartitions());
|
||||
} finally {
|
||||
olapTable.readUnlock();
|
||||
@ -1934,6 +1936,11 @@ public class SchemaChangeHandler extends AlterHandler {
|
||||
}
|
||||
}
|
||||
String storagePolicy = properties.get(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY);
|
||||
if (enableUniqueKeyMergeOnWrite && !Strings.isNullOrEmpty(storagePolicy)) {
|
||||
throw new UserException(
|
||||
"Can not set UNIQUE KEY table that enables Merge-On-write"
|
||||
+ " with storage policy(" + storagePolicy + ")");
|
||||
}
|
||||
long storagePolicyId = storagePolicyNameToId(storagePolicy);
|
||||
|
||||
if (isInMemory < 0 && storagePolicyId < 0) {
|
||||
@ -1969,6 +1976,12 @@ public class SchemaChangeHandler extends AlterHandler {
|
||||
}
|
||||
}
|
||||
String storagePolicy = properties.get(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY);
|
||||
boolean enableUniqueKeyMergeOnWrite = olapTable.getEnableUniqueKeyMergeOnWrite();
|
||||
if (enableUniqueKeyMergeOnWrite && !Strings.isNullOrEmpty(storagePolicy)) {
|
||||
throw new DdlException(
|
||||
"Can not set UNIQUE KEY table that enables Merge-On-write"
|
||||
+ " with storage policy(" + storagePolicy + ")");
|
||||
}
|
||||
long storagePolicyId = storagePolicyNameToId(storagePolicy);
|
||||
|
||||
if (isInMemory < 0 && storagePolicyId < 0) {
|
||||
|
||||
@ -25,6 +25,8 @@ import org.apache.doris.common.util.DynamicPartitionUtil;
|
||||
import org.apache.doris.common.util.PrintableMap;
|
||||
import org.apache.doris.common.util.PropertyAnalyzer;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
// clause which is used to modify table properties
|
||||
@ -101,7 +103,14 @@ public class ModifyTablePropertiesClause extends AlterTableClause {
|
||||
throw new AnalysisException("Alter tablet type not supported");
|
||||
} else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY)) {
|
||||
this.needTableStable = false;
|
||||
setStoragePolicy(properties.getOrDefault(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY, ""));
|
||||
String storagePolicy = properties.getOrDefault(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY, "");
|
||||
if (!Strings.isNullOrEmpty(storagePolicy)
|
||||
&& properties.containsKey(PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE)) {
|
||||
throw new AnalysisException(
|
||||
"Can not set UNIQUE KEY table that enables Merge-On-write"
|
||||
+ " with storage policy(" + storagePolicy + ")");
|
||||
}
|
||||
setStoragePolicy(storagePolicy);
|
||||
} else if (properties.containsKey(PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE)) {
|
||||
throw new AnalysisException("Can not change UNIQUE KEY to Merge-On-Write mode");
|
||||
} else {
|
||||
|
||||
@ -2013,6 +2013,12 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
// set storage policy
|
||||
String storagePolicy = PropertyAnalyzer.analyzeStoragePolicy(properties);
|
||||
Env.getCurrentEnv().getPolicyMgr().checkStoragePolicyExist(storagePolicy);
|
||||
if (olapTable.getEnableUniqueKeyMergeOnWrite()
|
||||
&& !Strings.isNullOrEmpty(storagePolicy)) {
|
||||
throw new AnalysisException(
|
||||
"Can not create UNIQUE KEY table that enables Merge-On-write"
|
||||
+ " with storage policy(" + storagePolicy + ")");
|
||||
}
|
||||
olapTable.setStoragePolicy(storagePolicy);
|
||||
|
||||
TTabletType tabletType;
|
||||
@ -2231,6 +2237,12 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
DistributionInfo partitionDistributionInfo = distributionDesc.toDistributionInfo(baseSchema);
|
||||
// use partition storage policy if it exist.
|
||||
String partionStoragePolicy = partitionInfo.getStoragePolicy(entry.getValue());
|
||||
if (olapTable.getEnableUniqueKeyMergeOnWrite()
|
||||
&& !Strings.isNullOrEmpty(partionStoragePolicy)) {
|
||||
throw new AnalysisException(
|
||||
"Can not create UNIQUE KEY table that enables Merge-On-write"
|
||||
+ " with storage policy(" + partionStoragePolicy + ")");
|
||||
}
|
||||
if (!partionStoragePolicy.equals("")) {
|
||||
storagePolicy = partionStoragePolicy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user