XieJiann commented on code in PR #27922:
URL: https://github.com/apache/doris/pull/27922#discussion_r1416612840


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewJoinRule.java:
##########
@@ -34,30 +45,52 @@ public abstract class AbstractMaterializedViewJoinRule 
extends AbstractMateriali
     protected Plan rewriteQueryByView(MatchMode matchMode,
             StructInfo queryStructInfo,
             StructInfo viewStructInfo,
-            RelationMapping queryToViewTableMappings,
-            Plan tempRewritedPlan) {
+            SlotMapping queryToViewSlotMappings,
+            Plan tempRewritedPlan,
+            MaterializationContext materializationContext) {
 
-        // Rewrite top projects, represent the query projects by view
-        List<NamedExpression> expressions = rewriteExpression(
+        List<? extends Expression> queryShuttleExpression = 
ExpressionUtils.shuttleExpressionWithLineage(
                 queryStructInfo.getExpressions(),
-                queryStructInfo,
-                viewStructInfo,
-                queryToViewTableMappings,
-                tempRewritedPlan
+                queryStructInfo.getOriginalPlan());
+        // Rewrite top projects, represent the query projects by view
+        List<Expression> expressionsRewritten = rewriteExpression(
+                queryShuttleExpression,
+                materializationContext.getViewExpressionIndexMapping(),
+                queryToViewSlotMappings
         );
         // Can not rewrite, bail out
-        if (expressions == null) {
+        if (expressionsRewritten == null
+                || expressionsRewritten.stream().anyMatch(expr -> !(expr 
instanceof NamedExpression))) {
             return null;
         }
-        return new LogicalProject<>(expressions, tempRewritedPlan);
+        if 
(queryStructInfo.getOriginalPlan().getGroupExpression().isPresent()) {
+            materializationContext.addMatchedGroup(
+                    
queryStructInfo.getOriginalPlan().getGroupExpression().get().getOwnerGroup().getGroupId());
+        }
+        return new LogicalProject<>(
+                
expressionsRewritten.stream().map(NamedExpression.class::cast).collect(Collectors.toList()),
+                tempRewritedPlan);
     }
 
     // Check join is whether valid or not. Support join's input can not 
contain aggregate
     // Only support project, filter, join, logical relation node and
     // join condition should be slot reference equals currently
     @Override
     protected boolean checkPattern(StructInfo structInfo) {
-        // TODO Should get struct info from hyper graph and check
-        return false;
+        HyperGraph hyperGraph = structInfo.getHyperGraph();
+        HashSet<JoinType> requiredJoinType = 
Sets.newHashSet(JoinType.INNER_JOIN, JoinType.LEFT_OUTER_JOIN);

Review Comment:
   This can be as a static member



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to