Skip to content

Commit

Permalink
[Enhancement] should do mv refresh when force refresh (#52081)
Browse files Browse the repository at this point in the history
Signed-off-by: kaijian.ding <[email protected]>
  • Loading branch information
kaijianding authored Dec 18, 2024
1 parent c954c87 commit 367311b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ public Set<String> getMVPartitionsToRefresh(PartitionInfo mvPartitionInfo,
// if use method below, it will break in the 2th TaskRun because ref-table has not updated in the
// specific start and end ranges.
return mvRangePartitionNames;
} else if (force) {
// should refresh all related partitions if user want to do force refresh
return mvRangePartitionNames;
} else {
// If the user specifies the start and end ranges, and the non-partitioned table still changes,
// it should be refreshed according to the user-specified range, not all partitions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ public void testStr2Date_DateTrunc() throws Exception {
materializedView.getPartitions().stream().map(Partition::getName).sorted()
.collect(Collectors.toList());
Assert.assertEquals(Arrays.asList("p000101_202308", "p202308_202309"), partitions);
Assert.assertEquals(partitionVersionMap.get("p202308_202309").longValue(),
// mv partition p202308_202309 is force refreshed and visible version is increased
Assert.assertEquals(partitionVersionMap.get("p202308_202309") + 1,
materializedView.getPartition("p202308_202309")
.getDefaultPhysicalPartition().getVisibleVersion());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,15 @@ public void testRangePartitionRefresh() throws Exception {
.getDefaultPhysicalPartition().getVisibleVersion());

refreshMVRange(materializedView.getName(), "2021-12-03", "2022-05-06", true);
Assert.assertEquals(2, materializedView.getPartition("p202112_202201")
Assert.assertEquals(3, materializedView.getPartition("p202112_202201")
.getDefaultPhysicalPartition().getVisibleVersion());
Assert.assertEquals(2, materializedView.getPartition("p202201_202202")
Assert.assertEquals(3, materializedView.getPartition("p202201_202202")
.getDefaultPhysicalPartition().getVisibleVersion());
Assert.assertEquals(1, materializedView.getPartition("p202202_202203")
Assert.assertEquals(2, materializedView.getPartition("p202202_202203")
.getDefaultPhysicalPartition().getVisibleVersion());
Assert.assertEquals(2, materializedView.getPartition("p202203_202204")
.getDefaultPhysicalPartition().getVisibleVersion());
Assert.assertEquals(2, materializedView.getPartition("p202204_202205")
Assert.assertEquals(3, materializedView.getPartition("p202204_202205")
.getDefaultPhysicalPartition().getVisibleVersion());
}

Expand Down

0 comments on commit 367311b

Please sign in to comment.