Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -335,20 +332,14 @@ private PhysicalPlan chooseBestPlan(Group rootGroup, PhysicalProperties physical
groupExpression.getOwnerGroup().getStatistics());
return physicalPlan;
} catch (Exception e) {
String memo = cascadesContext.getMemo().toString();
LOG.warn("Failed to choose best plan, memo structure:{}", memo, e);
throw new AnalysisException("Failed to choose best plan", e);
if (e instanceof AnalysisException && e.getMessage().contains("Failed to choose best plan")) {
throw e;
}
LOG.warn("Failed to choose best plan, memo structure:{}", cascadesContext.getMemo(), e);
throw new AnalysisException("Failed to choose best plan: " + e.getMessage(), e);
}
}

private ScheduledExecutorService runTimeoutExecutor() {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
Runnable task = () -> cascadesContext.setIsTimeout(true);
executor.schedule(task, 5, TimeUnit.SECONDS);

return executor;
}

/**
* getting hints explain string, which specified by enumerate and show in lists
* @param hintMap hint map recorded in statement context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,29 @@ public String toString() {
for (GroupExpression physicalExpression : physicalExpressions) {
str.append(" ").append(physicalExpression).append("\n");
}
str.append(" enforcers:\n");
str.append(" enforcers:\n");
for (GroupExpression enforcer : enforcers) {
str.append(" ").append(enforcer).append("\n");
}
if (chosenGroupExpressionId != -1) {
str.append(" chosen expression id: ").append(chosenGroupExpressionId).append("\n");
str.append(" chosen properties: ").append(chosenProperties).append("\n");
}
str.append(" stats").append("\n");
str.append(getStatistics() == null ? "" : getStatistics().detail(" "));
str.append(" lowest Plan(cost, properties, plan, childrenRequires)");
getAllProperties().forEach(
prop -> {
Optional<Pair<Cost, GroupExpression>> costAndGroupExpression = getLowestCostPlan(prop);
if (costAndGroupExpression.isPresent()) {
Cost cost = costAndGroupExpression.get().first;
GroupExpression child = costAndGroupExpression.get().second;
str.append("\n\n ").append(cost.getValue()).append(" ").append(prop)
.append("\n ").append(child).append("\n ")
.append(child.getInputPropertiesListOrEmpty(prop));
}
}
);
return str.toString();
}

Expand Down
18 changes: 1 addition & 17 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 @@ -779,23 +779,7 @@ public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("root:").append(getRoot()).append("\n");
for (Group group : groups.values()) {
builder.append("\n\n").append(group);
builder.append(" stats").append("\n");
builder.append(group.getStatistics().detail(" "));
builder.append(" lowest Plan(cost, properties, plan, childrenRequires)");
group.getAllProperties().forEach(
prop -> {
Optional<Pair<Cost, GroupExpression>> costAndGroupExpression = group.getLowestCostPlan(prop);
if (costAndGroupExpression.isPresent()) {
Cost cost = costAndGroupExpression.get().first;
GroupExpression child = costAndGroupExpression.get().second;
builder.append("\n\n " + cost.getValue() + " " + prop)
.append("\n ").append(child)
.append("\n " + child.getInputPropertiesListOrEmpty(prop));
}
}
);
builder.append("\n");
builder.append("\n\n").append(group).append("\n");
}
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private PhysicalProperties enforceDistributionButMeetSort(PhysicalProperties out
groupExpression.getOwnerGroup()
.replaceBestPlanProperty(
output, PhysicalProperties.ANY, groupExpression.getCostValueByProperties(output));
return enforceSortAndDistribution(output, request);
return enforceSortAndDistribution(PhysicalProperties.ANY, request);
}

private PhysicalProperties enforceGlobalSort(PhysicalProperties oldOutputProperty, PhysicalProperties required) {
Expand Down