Skip to content
Merged
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 @@ -94,6 +94,7 @@ public static boolean isMTMVPartitionSync(MTMVRefreshContext refreshContext, Str
Set<TableNameInfo> excludedTriggerTables) throws AnalysisException {
MTMV mtmv = refreshContext.getMtmv();
Map<MTMVRelatedTableIf, Set<String>> partitionMappings = refreshContext.getByPartitionName(partitionName);
Set<TableNameInfo> excludedTriggerTablesToCheck = Sets.newHashSet(excludedTriggerTables);
Comment thread
foxtail463 marked this conversation as resolved.
if (mtmv.getMvPartitionInfo().getPartitionType() != MTMVPartitionType.SELF_MANAGE) {
if (MapUtils.isEmpty(partitionMappings)) {
LOG.warn("can not found pct partition, partitionName: {}, mtmvName: {}",
Expand All @@ -104,7 +105,7 @@ 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(TableNameInfoUtils.fromCatalogDb(
excludedTriggerTablesToCheck.add(TableNameInfoUtils.fromCatalogDb(
pctTable.getDatabase().getCatalog(),
pctTable.getDatabase(), pctTable));
if (!isSyncWithPartitions(refreshContext, partitionName, relatedPartitionNames, pctTable)) {
Expand All @@ -114,7 +115,7 @@ public static boolean isMTMVPartitionSync(MTMVRefreshContext refreshContext, Str

}
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 @@ -171,6 +172,22 @@ 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"));
Mockito.when(context.getByPartitionName("name1")).thenReturn(partitionMappings);
Mockito.when(mtmvPartitionInfo.getPartitionType()).thenReturn(MTMVPartitionType.FOLLOW_BASE_TABLE);
Mockito.when(mtmvPartitionInfo.getPctTables()).thenReturn(Sets.newHashSet(baseOlapTable));

Set<TableNameInfo> 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