You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/12/01 12:00:54 UTC

[GitHub] [doris] jackwener commented on a diff in pull request #14691: [fix](Nereids): copy new Group in DPHyp to memo

jackwener commented on code in PR #14691:
URL: https://github.com/apache/doris/pull/14691#discussion_r1037026009


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/JoinOrderJob.java:
##########
@@ -77,7 +77,25 @@ private Group optimizeJoin(Group group) {
                 throw new RuntimeException("DPHyp can not enumerate all sub graphs with limit=" + limit);
             }
         }
-        return planReceiver.getBestPlan(hyperGraph.getNodesMap());
+
+        Group optimized = planReceiver.getBestPlan(hyperGraph.getNodesMap());
+        return copyToMemo(optimized);
+    }
+
+    private Group copyToMemo(Group root) {
+        if (!root.isJoinGroup()) {
+            return root;
+        }
+        GroupExpression groupExpression = root.getLogicalExpression();
+        int arity = groupExpression.arity();
+        for (int i = 0; i < arity; i++) {
+            Group childGroup = groupExpression.child(i);
+            Group newChildGroup = copyToMemo(childGroup);
+            groupExpression.setChild(i, newChildGroup);
+        }
+        Group newRoot = context.getCascadesContext().getMemo().copyInGroupExpression(groupExpression);

Review Comment:
   `copy into` mean that original plan still exist.
   Maybe you can try create a new Memo and copy in.🤔



-- 
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-unsubscribe@doris.apache.org

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


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