[feature](merge-on-write) enable merge-on-write by default again (#28105)
fix #27188, #28096
This commit is contained in:
@ -425,6 +425,7 @@ public class CreateTableStmt extends DdlStmt {
|
||||
if (keysDesc.getKeysType() == KeysType.UNIQUE_KEYS) {
|
||||
enableUniqueKeyMergeOnWrite = false;
|
||||
if (properties != null) {
|
||||
properties = PropertyAnalyzer.enableUniqueKeyMergeOnWriteIfNotExists(properties);
|
||||
// `analyzeXXX` would modify `properties`, which will be used later,
|
||||
// so we just clone a properties map here.
|
||||
enableUniqueKeyMergeOnWrite = PropertyAnalyzer.analyzeUniqueKeyMergeOnWrite(
|
||||
|
||||
@ -3243,8 +3243,8 @@ public class Env {
|
||||
sb.append(olapTable.getEstimatePartitionSize()).append("\"");
|
||||
}
|
||||
|
||||
// unique key table with merge on write
|
||||
if (olapTable.getKeysType() == KeysType.UNIQUE_KEYS && olapTable.getEnableUniqueKeyMergeOnWrite()) {
|
||||
// unique key table with merge on write, always print this property for unique table
|
||||
if (olapTable.getKeysType() == KeysType.UNIQUE_KEYS) {
|
||||
sb.append(",\n\"").append(PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE).append("\" = \"");
|
||||
sb.append(olapTable.getEnableUniqueKeyMergeOnWrite()).append("\"");
|
||||
}
|
||||
|
||||
@ -462,6 +462,9 @@ public class TableProperty implements Writable {
|
||||
properties.put(PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE, Boolean.toString(enable));
|
||||
}
|
||||
|
||||
// In order to ensure that unique tables without the `enable_unique_key_merge_on_write` property specified
|
||||
// before version 2.1 still maintain the merge-on-read implementation after the upgrade, we will keep
|
||||
// the default value here as false.
|
||||
public boolean getEnableUniqueKeyMergeOnWrite() {
|
||||
return Boolean.parseBoolean(properties.getOrDefault(
|
||||
PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE, "false"));
|
||||
|
||||
@ -1281,4 +1281,13 @@ public class PropertyAnalyzer {
|
||||
return properties;
|
||||
}
|
||||
|
||||
// Since we can't change the default value of the property `enable_unique_key_merge_on_write`
|
||||
// due to backward compatibility, we just explicitly set the value of this property to `true` if
|
||||
// the user doesn't specify the property in `CreateTableStmt`/`CreateTableInfo`
|
||||
public static Map<String, String> enableUniqueKeyMergeOnWriteIfNotExists(Map<String, String> properties) {
|
||||
if (properties != null && properties.get(PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE) == null) {
|
||||
properties.put(PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE, "true");
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ public class CreateTableInfo {
|
||||
if (keysType == KeysType.UNIQUE_KEYS) {
|
||||
isEnableMergeOnWrite = false;
|
||||
if (properties != null) {
|
||||
// properties = PropertyAnalyzer.enableUniqueKeyMergeOnWriteIfNotExists(properties);
|
||||
properties = PropertyAnalyzer.enableUniqueKeyMergeOnWriteIfNotExists(properties);
|
||||
// `analyzeXXX` would modify `properties`, which will be used later,
|
||||
// so we just clone a properties map here.
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user