Skip to content
Closed
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 @@ -60,8 +60,8 @@
public class QueryExplainer
{
public static final String DEPRECATED_TYPE_LOGICAL_WARNING = """
WARNING: EXPLAIN TYPE LOGICAL is no longer supported and will be removed in a future release.
Below is the output for EXPLAIN TYPE DISTRIBUTED. Please update your query.
WARNING: EXPLAIN [TYPE LOGICAL | TYPE DISTRIBUTED] is no longer supported and will be removed in a future release.
Below is the output for EXPLAIN <query>. Please update your query.

""";
private final List<PlanOptimizer> planOptimizers;
Expand Down Expand Up @@ -103,11 +103,10 @@ public String getPlan(Session session, Statement statement, Type planType, List<
}

return switch (planType) {
case LOGICAL -> {
case LOGICAL, DISTRIBUTED -> {
setDeprecatedTypeLogicalWarning(warningCollector);
yield DEPRECATED_TYPE_LOGICAL_WARNING + textDistributedPlan(session, statement, parameters, warningCollector, planOptimizersStatsCollector);
}
case DISTRIBUTED -> textDistributedPlan(session, statement, parameters, warningCollector, planOptimizersStatsCollector);
case IO -> textIoPlan(getLogicalPlan(session, statement, parameters, warningCollector, planOptimizersStatsCollector), plannerContext, session);
default -> throw new IllegalArgumentException("Unhandled plan type: " + planType);
};
Expand All @@ -133,11 +132,10 @@ public String getGraphvizPlan(Session session, Statement statement, Type planTyp
}

return switch (planType) {
case LOGICAL -> {
case LOGICAL, DISTRIBUTED -> {
setDeprecatedTypeLogicalWarning(warningCollector);
yield PlanPrinter.graphvizDistributedPlan(getDistributedPlan(session, statement, parameters, warningCollector, planOptimizersStatsCollector));
}
case DISTRIBUTED -> PlanPrinter.graphvizDistributedPlan(getDistributedPlan(session, statement, parameters, warningCollector, planOptimizersStatsCollector));
default -> throw new IllegalArgumentException("Unhandled plan type: " + planType);
};
}
Expand All @@ -152,11 +150,10 @@ public String getJsonPlan(Session session, Statement statement, Type planType, L

return switch (planType) {
case IO -> textIoPlan(getLogicalPlan(session, statement, parameters, warningCollector, planOptimizersStatsCollector), plannerContext, session);
case LOGICAL -> {
case LOGICAL, DISTRIBUTED -> {
setDeprecatedTypeLogicalWarning(warningCollector);
yield jsonDistributedPlan(session, statement, parameters, warningCollector, planOptimizersStatsCollector);
}
case DISTRIBUTED -> jsonDistributedPlan(session, statement, parameters, warningCollector, planOptimizersStatsCollector);
default -> throw new TrinoException(NOT_SUPPORTED, format("Unsupported explain plan type %s for JSON format", planType));
};
}
Expand All @@ -172,7 +169,7 @@ private String jsonDistributedPlan(Session session, Statement statement, List<Ex

private void setDeprecatedTypeLogicalWarning(WarningCollector warningCollector)
{
warningCollector.add(new TrinoWarning(DEPRECATED_SYNTAX, "EXPLAIN TYPE LOGICAL is deprecated. Please use EXPLAIN TYPE DISTRIBUTED instead."));
warningCollector.add(new TrinoWarning(DEPRECATED_SYNTAX, "EXPLAIN [TYPE LOGICAL | TYPE DISTRIBUTED] is deprecated. Please use EXPLAIN <query> instead."));
}

public Plan getLogicalPlan(Session session, Statement statement, List<Expression> parameters, WarningCollector warningCollector, PlanOptimizersStatsCollector planOptimizersStatsCollector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.BooleanType.BOOLEAN;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.sql.analyzer.QueryExplainer.DEPRECATED_TYPE_LOGICAL_WARNING;
import static io.trino.sql.tree.ExplainType.Type.DISTRIBUTED;
import static io.trino.sql.tree.ExplainType.Type.IO;
import static io.trino.sql.tree.ExplainType.Type.LOGICAL;
Expand Down Expand Up @@ -6013,7 +6012,7 @@ public void testLogicalExplainTextFormat()
String query = "SELECT * FROM orders";
MaterializedResult result = computeActual("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) " + query);
assertThat(getOnlyElement(result.getOnlyColumnAsSet())).isEqualTo(getExplainPlan(query, LOGICAL));
assertThat(getOnlyElement(result.getOnlyColumnAsSet())).isEqualTo(DEPRECATED_TYPE_LOGICAL_WARNING + getExplainPlan(query, DISTRIBUTED));
assertThat(getOnlyElement(result.getOnlyColumnAsSet())).isEqualTo(getExplainPlan(query, DISTRIBUTED));
}

@Test
Expand Down
Loading