Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static boolean isMTMVPartitionSync(MTMVRefreshContext refreshContext, Str
Set<TableName> excludedTriggerTables) throws AnalysisException {
MTMV mtmv = refreshContext.getMtmv();
Map<MTMVRelatedTableIf, Set<String>> partitionMappings = refreshContext.getByPartitionName(partitionName);
Set<TableName> excludedTriggerTablesToCheck = Sets.newHashSet(excludedTriggerTables);
if (mtmv.getMvPartitionInfo().getPartitionType() != MTMVPartitionType.SELF_MANAGE) {
if (MapUtils.isEmpty(partitionMappings)) {
LOG.warn("can not found pct partition, partitionName: {}, mtmvName: {}",
Expand All @@ -103,15 +104,15 @@ public static boolean isMTMVPartitionSync(MTMVRefreshContext refreshContext, Str
for (MTMVRelatedTableIf pctTable : pctTables) {
Set<String> relatedPartitionNames = partitionMappings.getOrDefault(pctTable, Sets.newHashSet());
// if follow base table, not need compare with related table, only should compare with related partition
excludedTriggerTables.add(new TableName(pctTable));
excludedTriggerTablesToCheck.add(new TableName(pctTable));
if (!isSyncWithPartitions(refreshContext, partitionName, relatedPartitionNames, pctTable)) {
return false;
}
}

}
return isSyncWithAllBaseTables(refreshContext, partitionName, tables,
excludedTriggerTables);
excludedTriggerTablesToCheck);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.doris.datasource.CatalogIf;
import org.apache.doris.mtmv.MTMVPartitionInfo.MTMVPartitionType;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -240,6 +241,34 @@ public void testIsSyncWithPartitionNotSync() throws AnalysisException {
Assert.assertFalse(isSyncWithPartition);
}

@Test
public void testIsMTMVPartitionSyncWithImmutableExcludedTriggerTables() throws AnalysisException {
Map<MTMVRelatedTableIf, Set<String>> partitionMappings = Maps.newHashMap();
partitionMappings.put(baseOlapTable, Sets.newHashSet("name2"));
new Expectations() {
{
context.getByPartitionName("name1");
minTimes = 0;
result = partitionMappings;

mtmvPartitionInfo.getPartitionType();
minTimes = 0;
result = MTMVPartitionType.FOLLOW_BASE_TABLE;

mtmvPartitionInfo.getPctTables();
minTimes = 0;
result = Sets.newHashSet(baseOlapTable);
}
};

Set<TableName> excludedTriggerTables = ImmutableSet.of();
boolean isMTMVPartitionSync = MTMVPartitionUtil.isMTMVPartitionSync(context, "name1", baseTables,
excludedTriggerTables);

Assert.assertTrue(isMTMVPartitionSync);
Assert.assertTrue(excludedTriggerTables.isEmpty());
}

@Test
public void testGeneratePartitionName() {
List<List<PartitionValue>> inValues = Lists.newArrayList();
Expand Down
Loading