Skip to content

Commit

Permalink
fix test again
Browse files Browse the repository at this point in the history
  • Loading branch information
seawinde committed Jan 9, 2025
1 parent 508d2e9 commit db4fd68
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public Plan rewriteRoot(Plan plan, JobContext jobContext) {
public Plan visitLogicalCatalogRelation(LogicalCatalogRelation catalogRelation, ConnectContext context) {

TableIf table = catalogRelation.getTable();
if (table.getDatabase() == null) {
// logic for test
return catalogRelation;
}
BaseTableInfo relatedPartitionTable = new BaseTableInfo(table);
Map<BaseTableInfo, Set<String>> tableUsedPartitionNameMap = context.getStatementContext()
.getTableUsedPartitionNameMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,22 @@ public boolean isMVPartitionValid(MTMV mtmv, ConnectContext ctx, boolean isMVPar
.getTableUsedPartitionNameMap();
Map<BaseTableInfo, Collection<Partition>> mvCanRewritePartitionsMap = c1.getStatementContext()
.getMvCanRewritePartitionsMap();
Assertions.assertTrue(tableUsedPartitionNameMap.isEmpty());
Assertions.assertFalse(mvCanRewritePartitionsMap.keySet().isEmpty());
Assertions.assertEquals(mvCanRewritePartitionsMap.keySet().iterator().next().getTableName(),
"mv1");
Assertions.assertFalse(tableUsedPartitionNameMap.isEmpty());

for (Map.Entry<BaseTableInfo, Set<String>> tableInfoEntry : tableUsedPartitionNameMap.entrySet()) {
if (tableInfoEntry.getKey().getTableName().equalsIgnoreCase("t2")) {
Assertions.assertEquals(tableInfoEntry.getValue(), Sets.newHashSet("T2"));
} else if (tableInfoEntry.getKey().getTableName().equalsIgnoreCase("t3")) {
Assertions.assertEquals(tableInfoEntry.getValue(), Sets.newHashSet("T3"));
} else if (tableInfoEntry.getKey().getTableName().equalsIgnoreCase("t4")) {
Assertions.assertTrue(tableInfoEntry.getValue().isEmpty());
}
}

Assertions.assertEquals(1, mvCanRewritePartitionsMap.size());
Assertions.assertTrue(mvCanRewritePartitionsMap.keySet().iterator().next().getTableName()
.equalsIgnoreCase("mv1"));

dropMvByNereids("drop materialized view mv1");
}

Expand Down Expand Up @@ -197,15 +209,20 @@ public DistributionInfoType getType() {
.getMvCanRewritePartitionsMap();
Assertions.assertFalse(tableUsedPartitionNameMap.isEmpty());

BaseTableInfo t4 = tableUsedPartitionNameMap.keySet().iterator().next();
Assertions.assertEquals(t4.getTableName().toLowerCase(), "t4");
for (Map.Entry<BaseTableInfo, Set<String>> tableInfoEntry : tableUsedPartitionNameMap.entrySet()) {
if (tableInfoEntry.getKey().getTableName().equalsIgnoreCase("t2")) {
Assertions.assertEquals(tableInfoEntry.getValue(), Sets.newHashSet("mock_partition"));
} else if (tableInfoEntry.getKey().getTableName().equalsIgnoreCase("t3")) {
Assertions.assertEquals(tableInfoEntry.getValue(), Sets.newHashSet("mock_partition"));
} else if (tableInfoEntry.getKey().getTableName().equalsIgnoreCase("t4")) {
Assertions.assertEquals(tableInfoEntry.getValue(), Sets.newHashSet("mock_partition"));
}
}

Set<String> partitionNames = tableUsedPartitionNameMap.get(t4);
Assertions.assertEquals(partitionNames, Sets.newHashSet("mock_partition"));
Assertions.assertEquals(1, mvCanRewritePartitionsMap.size());
Assertions.assertTrue(mvCanRewritePartitionsMap.keySet().iterator().next().getTableName()
.equalsIgnoreCase("mv2"));

Assertions.assertFalse(mvCanRewritePartitionsMap.keySet().isEmpty());
Assertions.assertEquals(mvCanRewritePartitionsMap.keySet().iterator().next().getTableName(),
"mv2");
dropMvByNereids("drop materialized view mv2");
}
}

0 comments on commit db4fd68

Please sign in to comment.