[fix](catalog recycle bin) Forbid recover partition if table schame is changed #31146

This commit is contained in:
meiyi
2024-02-20 22:18:52 +08:00
committed by yiguolei
parent 872e1f6687
commit 1d6dc9a5f0
4 changed files with 177 additions and 1 deletions

View File

@ -810,8 +810,17 @@ public class CatalogRecycleBin extends MasterDaemon implements Writable {
throw new DdlException("Can not recover partition[" + partitionName + "]. Partition item conflict.");
}
// check if partition name exists
// check if schema change
Partition recoverPartition = recoverPartitionInfo.getPartition();
Set<Long> tableIndex = table.getIndexIdToMeta().keySet();
Set<Long> partitionIndex = recoverPartition.getMaterializedIndices(IndexExtState.ALL).stream()
.map(i -> i.getId()).collect(Collectors.toSet());
if (!tableIndex.equals(partitionIndex)) {
throw new DdlException("table's index not equal with partition's index. table's index=" + tableIndex
+ ", partition's index=" + partitionIndex);
}
// check if partition name exists
Preconditions.checkState(recoverPartition.getName().equalsIgnoreCase(partitionName));
if (!Strings.isNullOrEmpty(newPartitionName)) {
if (table.checkPartitionNameExist(newPartitionName)) {