Skip to content

Commit b94e6fc

Browse files
committed
Use pre-order stages ordering in EXPLAN output
1 parent 39d8bda commit b94e6fc

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

core/trino-main/src/main/java/io/trino/operator/ExplainAnalyzeOperator.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.concurrent.TimeUnit;
2929

3030
import static com.google.common.base.Preconditions.checkState;
31-
import static com.google.common.collect.ImmutableList.toImmutableList;
3231
import static io.trino.spi.type.VarcharType.VARCHAR;
3332
import static io.trino.sql.planner.planprinter.PlanPrinter.textDistributedPlan;
3433
import static java.util.Objects.requireNonNull;
@@ -153,15 +152,14 @@ public Page getOutput()
153152

154153
QueryInfo queryInfo = queryPerformanceFetcher.getQueryInfo(operatorContext.getDriverContext().getTaskId().getQueryId());
155154
checkState(queryInfo.getStages().isPresent(), "Stages informations is missing");
156-
checkState(queryInfo.getStages().get().getOutputStage().getSubStages().size() == 1, "Expected one sub stage of explain node");
155+
StagesInfo stagesInfo = queryInfo.getStages().get();
156+
checkState(stagesInfo.getOutputStage().getSubStages().size() == 1, "Expected one sub stage of explain node");
157157

158-
if (!hasFinalStageInfo(queryInfo.getStages().get())) {
158+
if (!hasFinalStageInfo(stagesInfo)) {
159159
return null;
160160
}
161161

162-
List<StageInfo> stagesWithoutOutputStage = queryInfo.getStages().orElseThrow().getStages().stream()
163-
.filter(stage -> !stage.getStageId().equals(queryInfo.getStages().orElseThrow().getOutputStageId()))
164-
.collect(toImmutableList());
162+
List<StageInfo> stagesWithoutOutputStage = stagesInfo.getSubStagesDeepPreOrder(stagesInfo.getOutputStageId(), false);
165163

166164
String plan = textDistributedPlan(
167165
stagesWithoutOutputStage,

core/trino-main/src/main/java/io/trino/sql/planner/planprinter/PlanPrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public static String textDistributedPlan(
428428
Anonymizer anonymizer,
429429
NodeVersion version)
430430
{
431-
return textDistributedPlan(stages.getStages(), queryStats, valuePrinter, verbose, anonymizer, version);
431+
return textDistributedPlan(stages.getSubStagesDeepPreOrder(stages.getOutputStageId(), true), queryStats, valuePrinter, verbose, anonymizer, version);
432432
}
433433

434434
public static String textDistributedPlan(

0 commit comments

Comments
 (0)