morrySnow commented on code in PR #9807:
URL: https://github.com/apache/incubator-doris/pull/9807#discussion_r885236825


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ApplyRuleJob.java:
##########
@@ -53,20 +54,19 @@ public ApplyRuleJob(GroupExpression groupExpression, 
Rule<Plan> rule, PlannerCon
 
     @Override
     public void execute() throws AnalysisException {
-        if (groupExpression.hasExplored(rule)) {
+        if (groupExpression.hasApplied(rule)) {
             return;
         }
 
         // TODO: need to find all plan reference tree that match this pattern
-        PatternMatching patternMatching = new PatternMatching();
-        for (Plan<?, ?> plan : patternMatching) {
-            if (!rule.check(plan, context)) {
-                continue;
-            }
-            List<Plan> newPlanList = rule.transform(plan, context);
-            for (Plan newPlan : newPlanList) {
+        GroupExpressionMatching<Plan> groupExpressionMatching
+                = new GroupExpressionMatching(rule.getPattern(), 
groupExpression);
+        for (TreeNode treeNode : groupExpressionMatching) {
+            Plan plan = (Plan) treeNode;
+            List<Plan> newPlans = rule.transform(plan, context);
+            for (Plan newPlan : newPlans) {
                 GroupExpression newGroupExpression = 
context.getOptimizerContext().getMemo()
-                        .newGroupExpression(newPlan, 
groupExpression.getParent());
+                        .copyIn(newPlan, groupExpression.getParent(), 
rule.isRewrite());
                 // TODO need to check return is a new Reference, other wise 
will be into a dead loop
                 if (newPlan instanceof LogicalPlan) {
                     pushTask(new DeriveStatsJob(newGroupExpression, context));

Review Comment:
   yes



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to