branch-2.1-pick: [Opt](mow) Forbid time_series compaction policy on unique table (#49905) (#50132)

pick https://github.com/apache/doris/pull/49905
This commit is contained in:
bobhan1
2025-04-18 11:34:18 +08:00
committed by GitHub
parent 77ea907b54
commit 4146cbbbbb
5 changed files with 92 additions and 3 deletions

View File

@ -2242,6 +2242,11 @@ public class SchemaChangeHandler extends AlterHandler {
+ " or " + PropertyAnalyzer.SIZE_BASED_COMPACTION_POLICY);
}
if (compactionPolicy != null && compactionPolicy.equals(PropertyAnalyzer.TIME_SERIES_COMPACTION_POLICY)
&& olapTable.getKeysType() == KeysType.UNIQUE_KEYS) {
throw new UserException("Time series compaction policy is not supported for unique key table");
}
Map<String, Long> timeSeriesCompactionConfig = new HashMap<>();
if (properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES)) {
timeSeriesCompactionConfig

View File

@ -747,7 +747,8 @@ public class PropertyAnalyzer {
+ " must be `true` or `false`");
}
public static String analyzeCompactionPolicy(Map<String, String> properties) throws AnalysisException {
public static String analyzeCompactionPolicy(Map<String, String> properties, KeysType keysType)
throws AnalysisException {
if (properties == null || properties.isEmpty()) {
return SIZE_BASED_COMPACTION_POLICY;
}
@ -762,6 +763,9 @@ public class PropertyAnalyzer {
}
}
if (keysType == KeysType.UNIQUE_KEYS && compactionPolicy.equals(TIME_SERIES_COMPACTION_POLICY)) {
throw new AnalysisException("Time series compaction policy is not supported for unique key table");
}
return compactionPolicy;
}

View File

@ -2399,7 +2399,7 @@ public class InternalCatalog implements CatalogIf<Database> {
// set compaction policy
String compactionPolicy = PropertyAnalyzer.SIZE_BASED_COMPACTION_POLICY;
try {
compactionPolicy = PropertyAnalyzer.analyzeCompactionPolicy(properties);
compactionPolicy = PropertyAnalyzer.analyzeCompactionPolicy(properties, olapTable.getKeysType());
} catch (AnalysisException e) {
throw new DdlException(e.getMessage());
}