[fix](mtmv)fix when related table drop partition,mv partition is sync… (#36602)

pick: https://github.com/apache/doris/pull/36547
This commit is contained in:
zhangdong
2024-07-02 23:08:58 +08:00
committed by GitHub
parent 5bb6642b86
commit 03942f23f6
3 changed files with 32 additions and 0 deletions

View File

@ -325,6 +325,11 @@ public class MTMVPartitionUtil {
if (!relatedTable.needAutoRefresh()) {
return true;
}
// check if partitions of related table if changed
Set<String> snapshotPartitions = mtmv.getRefreshSnapshot().getSnapshotPartitions(mtmvPartitionName);
if (!Objects.equals(relatedPartitionNames, snapshotPartitions)) {
return false;
}
for (String relatedPartitionName : relatedPartitionNames) {
MTMVSnapshotIf relatedPartitionCurrentSnapshot = relatedTable
.getPartitionSnapshot(relatedPartitionName);

View File

@ -18,6 +18,7 @@
package org.apache.doris.mtmv;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.annotations.SerializedName;
import org.apache.commons.collections.MapUtils;
@ -46,6 +47,14 @@ public class MTMVRefreshSnapshot {
return relatedPartitionSnapshot.equals(relatedPartitionCurrentSnapshot);
}
public Set<String> getSnapshotPartitions(String mtmvPartitionName) {
MTMVRefreshPartitionSnapshot partitionSnapshot = partitionSnapshots.get(mtmvPartitionName);
if (partitionSnapshot == null) {
return Sets.newHashSet();
}
return partitionSnapshot.getPartitions().keySet();
}
public boolean equalsWithBaseTable(String mtmvPartitionName, long baseTableId,
MTMVSnapshotIf baseTableCurrentSnapshot) {
MTMVRefreshPartitionSnapshot partitionSnapshot = partitionSnapshots.get(mtmvPartitionName);