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 @@ -16,6 +16,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableList;
import io.trino.cost.LocalCostEstimate;
import io.trino.cost.PlanCostEstimate;
import io.trino.cost.PlanNodeStatsAndCostSummary;
import io.trino.cost.PlanNodeStatsEstimate;
Expand Down Expand Up @@ -151,14 +152,14 @@ public Optional<PlanNodeStatsAndCostSummary> getReorderJoinStatsAndCost()
public List<PlanNodeStatsAndCostSummary> getEstimates(TypeProvider typeProvider)
{
if (getEstimatedStats().stream().allMatch(PlanNodeStatsEstimate::isOutputRowCountUnknown) &&
getEstimatedCost().stream().allMatch(c -> c.equals(PlanCostEstimate.unknown()))) {
getEstimatedCost().stream().allMatch(c -> c.getRootNodeLocalCostEstimate().equals(LocalCostEstimate.unknown()))) {
return ImmutableList.of();
}

ImmutableList.Builder<PlanNodeStatsAndCostSummary> estimates = ImmutableList.builder();
for (int i = 0; i < getEstimatedStats().size(); i++) {
PlanNodeStatsEstimate stats = getEstimatedStats().get(i);
PlanCostEstimate cost = getEstimatedCost().get(i);
LocalCostEstimate cost = getEstimatedCost().get(i).getRootNodeLocalCostEstimate();
Comment thread
sopel39 marked this conversation as resolved.
Outdated

List<Symbol> outputSymbols = getOutputs().stream()
.map(NodeRepresentation.TypedSymbol::getSymbol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ private String writeTextOutput(StringBuilder output, PlanRepresentation plan, In
output.append(indentMultilineString(reorderJoinStatsAndCost, indent.detailIndent()));
}

String estimates = printEstimates(plan, node);
List<PlanNodeStatsAndCostSummary> estimates = node.getEstimates(plan.getTypes());
if (!estimates.isEmpty()) {
output.append(indentMultilineString(estimates, indent.detailIndent()));
output.append(indentMultilineString(printEstimates(estimates), indent.detailIndent()));
}

String stats = printStats(plan, node);
Expand Down Expand Up @@ -265,9 +265,9 @@ private String printReorderJoinStatsAndCost(NodeRepresentation node)
return "";
}

private String printEstimates(PlanRepresentation plan, NodeRepresentation node)
private String printEstimates(List<PlanNodeStatsAndCostSummary> estimates)
{
return node.getEstimates(plan.getTypes()).stream()
return estimates.stream()
.map(this::formatPlanNodeStatsAndCostSummary)
.collect(joining("/", "Estimates: ", "\n"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public void testDistributedJsonPlan()
ImmutableMap.of("columnNames", "[quantity]"),
ImmutableList.of(typedSymbol("quantity", "double")),
ImmutableList.of(),
ImmutableList.of(new PlanNodeStatsAndCostSummary(10, 90, 541665, 0, 0)),
ImmutableList.of(new PlanNodeStatsAndCostSummary(10, 90, 0, 0, 0)),
ImmutableList.of(new JsonRenderedNode(
"98",
"Limit",
ImmutableMap.of("count", "10", "withTies", "", "inputPreSortedBy", "[]"),
ImmutableList.of(typedSymbol("quantity", "double")),
ImmutableList.of(),
ImmutableList.of(new PlanNodeStatsAndCostSummary(10, 90, 541665, 0, 0)),
ImmutableList.of(new PlanNodeStatsAndCostSummary(10, 90, 90, 0, 0)),
ImmutableList.of(new JsonRenderedNode(
"147",
"LocalExchange",
Expand All @@ -102,7 +102,7 @@ public void testDistributedJsonPlan()
"arguments", "[]"),
ImmutableList.of(typedSymbol("quantity", "double")),
ImmutableList.of(),
ImmutableList.of(new PlanNodeStatsAndCostSummary(60175, 541575, 541575, 0, 0)),
ImmutableList.of(new PlanNodeStatsAndCostSummary(60175, 541575, 0, 0, 0)),
ImmutableList.of(new JsonRenderedNode(
"0",
"TableScan",
Expand All @@ -111,7 +111,7 @@ public void testDistributedJsonPlan()
ImmutableList.of("quantity := tpch:quantity"),
ImmutableList.of(new PlanNodeStatsAndCostSummary(60175, 541575, 541575, 0, 0)),
ImmutableList.of()))))))));
MaterializedResult expectedPlan = resultBuilder(queryRunner.getDefaultSession(), createVarcharType(2072))
MaterializedResult expectedPlan = resultBuilder(queryRunner.getDefaultSession(), createVarcharType(2058))
.row(DISTRIBUTED_PLAN_JSON_CODEC.toJson(distributedPlan))
.build();
assertThat(actualPlan).isEqualTo(expectedPlan);
Expand All @@ -127,14 +127,14 @@ public void testLogicalJsonPlan()
ImmutableMap.of("columnNames", "[quantity]"),
ImmutableList.of(typedSymbol("quantity", "double")),
ImmutableList.of(),
ImmutableList.of(new PlanNodeStatsAndCostSummary(10, 90, 541665, 0, 0)),
ImmutableList.of(new PlanNodeStatsAndCostSummary(10, 90, 0, 0, 0)),
ImmutableList.of(new JsonRenderedNode(
"98",
"Limit",
ImmutableMap.of("count", "10", "withTies", "", "inputPreSortedBy", "[]"),
ImmutableList.of(typedSymbol("quantity", "double")),
ImmutableList.of(),
ImmutableList.of(new PlanNodeStatsAndCostSummary(10, 90, 541665, 0, 0)),
ImmutableList.of(new PlanNodeStatsAndCostSummary(10, 90, 90, 0, 0)),
ImmutableList.of(new JsonRenderedNode(
"147",
"LocalExchange",
Expand All @@ -145,7 +145,7 @@ public void testLogicalJsonPlan()
"arguments", "[]"),
ImmutableList.of(typedSymbol("quantity", "double")),
ImmutableList.of(),
ImmutableList.of(new PlanNodeStatsAndCostSummary(60175, 541575, 541575, 0, 0)),
ImmutableList.of(new PlanNodeStatsAndCostSummary(60175, 541575, 0, 0, 0)),
ImmutableList.of(new JsonRenderedNode(
"0",
"TableScan",
Expand All @@ -154,7 +154,7 @@ public void testLogicalJsonPlan()
ImmutableList.of("quantity := tpch:quantity"),
ImmutableList.of(new PlanNodeStatsAndCostSummary(60175, 541575, 541575, 0, 0)),
ImmutableList.of())))))));
MaterializedResult expectedPlan = resultBuilder(queryRunner.getDefaultSession(), createVarcharType(1898))
MaterializedResult expectedPlan = resultBuilder(queryRunner.getDefaultSession(), createVarcharType(1884))
.row(JSON_RENDERED_NODE_CODEC.toJson(expectedJsonNode))
.build();
assertThat(actualPlan).isEqualTo(expectedPlan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static LocalQueryRunner createLocalQueryRunner()
.build();

LocalQueryRunner localQueryRunner = LocalQueryRunner.builder(defaultSession)
.withNodeCountForStats(1)
.build();

// add the tpch catalog
Expand Down