diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/mapping/RelationMapping.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/mapping/RelationMapping.java index de7e55d6da8c83..b5494c01b1b924 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/mapping/RelationMapping.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/mapping/RelationMapping.java @@ -74,9 +74,9 @@ public static List generate(List sources, List Set sourceTableKeySet = sourceTableRelationIdMap.keySet(); List>> mappedRelations = new ArrayList<>(); - for (Long sourceTableQualifier : sourceTableKeySet) { - Set sourceMappedRelations = sourceTableRelationIdMap.get(sourceTableQualifier); - Set targetMappedRelations = targetTableRelationIdMap.get(sourceTableQualifier); + for (Long sourceTableId : sourceTableKeySet) { + Set sourceMappedRelations = sourceTableRelationIdMap.get(sourceTableId); + Set targetMappedRelations = targetTableRelationIdMap.get(sourceTableId); if (targetMappedRelations.isEmpty()) { continue; } @@ -89,12 +89,13 @@ public static List generate(List sources, List continue; } // relation appear more than once, should cartesian them and power set to correct combination - // if query is a0, a1, view is b0, b1 + // if query is select * from tableA0, tableA1, materialized view is select * from tableA2, tableA3, + // tableA is the same table used by both query and materialized view // relationMapping will be - // a0 b0 - // a0 b1 - // a1 b0 - // a1 b1 + // tableA0 tableA2 + // tableA0 tableA3 + // tableA1 tableA2 + // tableA1 tableA3 ImmutableList> relationMapping = Sets.cartesianProduct( sourceMappedRelations, targetMappedRelations) .stream() @@ -103,8 +104,8 @@ public static List generate(List sources, List // the mapping in relationMappingPowerList should be bi-direction // [ - // {a0-b0, a1-b1} - // {a1-b0, a0-b1} + // {tableA0 tableA2, tableA1 tableA3} + // {tableA0 tableA3, tableA1 tableA2} // ] List> relationMappingPowerList = new ArrayList<>(); int relationMappingSize = relationMapping.size();