jackwener commented on code in PR #18687: URL: https://github.com/apache/doris/pull/18687#discussion_r1171265536
########## fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java: ########## @@ -450,21 +451,23 @@ private CopyInResult insertGroupExpression( * * @param source source group * @param destination destination group - * @return merged group */ - public Group mergeGroup(Group source, Group destination) { + public void mergeGroup(Group source, Group destination) { if (source.equals(destination)) { - return source; + return; } List<GroupExpression> needReplaceChild = Lists.newArrayList(); - for (GroupExpression groupExpression : groupExpressions.values()) { - if (groupExpression.children().contains(source)) { - if (groupExpression.getOwnerGroup().equals(destination)) { - // cycle, we should not merge - return null; - } - needReplaceChild.add(groupExpression); + for (GroupExpression parent : source.getParentGroupExpressions()) { + if (parent.getOwnerGroup().equals(destination)) { Review Comment: It's a good question, we need think about it in following PR. -- 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