Skip to content

Commit

Permalink
[fix](Nereids) fix plan shape of query64 unstable (apache#26012) (apa…
Browse files Browse the repository at this point in the history
…che#26775)

don't remove the physical plan after optimizing the plan in dphyper.
  • Loading branch information
keanji-x committed Nov 10, 2023
1 parent a63c353 commit 6f62cb6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ private void dpHypOptimize() {
// Due to EnsureProjectOnTopJoin, root group can't be Join Group, so DPHyp doesn't change the root group
cascadesContext.pushJob(new JoinOrderJob(root, cascadesContext.getCurrentJobContext()));
cascadesContext.getJobScheduler().executeJobPool(cascadesContext);
// after DPHyp just keep logical expression
cascadesContext.getMemo().removePhysicalExpression();
cascadesContext.getStatementContext().setOtherJoinReorder(true);
}

Expand Down
26 changes: 0 additions & 26 deletions fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -111,31 +110,6 @@ public int getGroupExpressionsSize() {
return groupExpressions.size();
}

/** just keep LogicalExpression in Memo. */
public void removePhysicalExpression() {
groupExpressions.entrySet().removeIf(entry -> entry.getValue().getPlan() instanceof PhysicalPlan);

Iterator<Map.Entry<GroupId, Group>> iterator = groups.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<GroupId, Group> entry = iterator.next();
Group group = entry.getValue();

group.clearPhysicalExpressions();
group.clearLowestCostPlans();
group.removeParentPhysicalExpressions();
group.setExplored(false);

if (group.getLogicalExpressions().isEmpty() && group.getPhysicalExpressions().isEmpty()) {
iterator.remove();
}
}

// logical groupExpression reset ruleMask
groupExpressions.values().stream()
.filter(groupExpression -> groupExpression.getPlan() instanceof LogicalPlan)
.forEach(GroupExpression::clearApplied);
}

private Plan skipProject(Plan plan, Group targetGroup) {
// Some top project can't be eliminated
if (plan instanceof LogicalProject && ((LogicalProject<?>) plan).canEliminate()) {
Expand Down

0 comments on commit 6f62cb6

Please sign in to comment.