Skip to content

Commit

Permalink
[BugFix] Ignore to refresh if base table has dropped one partition (#…
Browse files Browse the repository at this point in the history
…52740)

Signed-off-by: shuming.li <[email protected]>
  • Loading branch information
LiShuMing authored Nov 19, 2024
1 parent 84c4abd commit 5b50628
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ public Set<String> getUpdatedPartitionNames(List<BaseTableInfo> baseTables,
for (Map.Entry<String, MaterializedView.BasePartitionInfo> versionEntry : versionMap.entrySet()) {
String basePartitionName = versionEntry.getKey();
if (!latestPartitionInfo.containsKey(basePartitionName)) {
// TODO: If one partition has been dropped, refresh all existed partitions again.
return latestPartitionInfo.keySet();
// If this partition is dropped, ignore it.
continue;
}
long basePartitionVersion = latestPartitionInfo.get(basePartitionName).getModifiedTime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public Set<String> getUpdatedPartitionNames(List<BaseTableInfo> baseTables,
String basePartitionName = versionEntry.getKey();
Partition basePartition = baseTable.getPartition(basePartitionName);
if (basePartition == null) {
// TODO: Once there is a partition deleted, refresh all partitions.
return baseTable.getVisiblePartitionNames();
// If this partition is dropped, ignore it.
continue;
}
MaterializedView.BasePartitionInfo mvRefreshedPartitionInfo = versionEntry.getValue();
if (mvRefreshedPartitionInfo == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,7 @@ public void testHivePartitionPruneNonRefBaseTable1() throws Exception {

MvTaskRunContext mvContext = processor.getMvContext();
ExecPlan execPlan = mvContext.getExecPlan();
String plan = execPlan.getExplainString(TExplainLevel.NORMAL);
Assert.assertTrue(execPlan != null);
Assert.assertNull(execPlan);
}

// run 5
Expand All @@ -929,15 +928,7 @@ public void testHivePartitionPruneNonRefBaseTable1() throws Exception {

MvTaskRunContext mvContext = processor.getMvContext();
ExecPlan execPlan = mvContext.getExecPlan();
String plan = execPlan.getExplainString(TExplainLevel.NORMAL);
PlanTestBase.assertContains(plan, "TABLE: part_tbl1\n" +
" PARTITION PREDICATES: 4: par_date IS NOT NULL, 4: par_date >= '2020-01-01', 4: par_date < " +
"'2020-01-05'\n" +
" partitions=4/4");
PlanTestBase.assertContains(plan, "TABLE: part_tbl2\n" +
" PARTITION PREDICATES: 8: par_date IS NOT NULL, 8: par_date >= '2020-01-01', 8: par_date < " +
"'2020-01-05'\n" +
" partitions=4/4");
Assert.assertNull(execPlan);
}

starRocksAssert.dropMaterializedView("hive_partition_prune_non_ref_tables2");
Expand Down Expand Up @@ -1338,10 +1329,7 @@ public void testCreateMVWithMultiPartitionColumns1() throws Exception {
taskRun.getProcessor();
MvTaskRunContext mvContext = processor.getMvContext();
ExecPlan execPlan = mvContext.getExecPlan();
String plan = execPlan.getExplainString(TExplainLevel.NORMAL);
// TODO(fixme): drop partition should not refresh all partitions.
PlanTestBase.assertContains(plan, " TABLE: t1_par\n");
PlanTestBase.assertContains(plan, " partitions=6/6");
Assert.assertTrue(execPlan == null);
}
starRocksAssert.dropMaterializedView("test_mv1");
}
Expand Down Expand Up @@ -1404,9 +1392,7 @@ public void testCreateMVWithMultiPartitionColumns2() throws Exception {
PartitionBasedMvRefreshProcessor processor = (PartitionBasedMvRefreshProcessor) taskRun.getProcessor();
MvTaskRunContext mvContext = processor.getMvContext();
ExecPlan execPlan = mvContext.getExecPlan();
String plan = execPlan.getExplainString(TExplainLevel.NORMAL);
PlanTestBase.assertContains(plan, " TABLE: t1_par\n");
PlanTestBase.assertContains(plan, " partitions=6/6");
Assert.assertTrue(execPlan == null);
}
starRocksAssert.dropMaterializedView("test_mv1");
}
Expand Down

0 comments on commit 5b50628

Please sign in to comment.