Skip to content

Commit

Permalink
Print current plan when dynamic filters invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi authored and losipiuk committed Oct 13, 2021
1 parent bbdf5b6 commit ca48ae4
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import io.trino.Session;
import io.trino.cost.StatsAndCosts;
import io.trino.execution.warnings.WarningCollector;
import io.trino.metadata.Metadata;
import io.trino.spi.type.TypeOperators;
Expand Down Expand Up @@ -44,6 +45,7 @@
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.intersection;
import static io.trino.sql.planner.planprinter.PlanPrinter.textLogicalPlan;

/**
* When dynamic filter assignments are present on a Join node, they should be consumed by a Filter node on it's probe side
Expand All @@ -60,6 +62,24 @@ public void validate(
TypeAnalyzer typeAnalyzer,
TypeProvider types,
WarningCollector warningCollector)
{
try {
validate(plan);
}
catch (RuntimeException e) {
try {
int nestLevel = 4; // so that it renders reasonably within exception stacktrace
String explain = textLogicalPlan(plan, types, metadata, StatsAndCosts.empty(), session, nestLevel, false);
e.addSuppressed(new Exception("Current plan:\n" + explain));
}
catch (RuntimeException ignore) {
// ignored
}
throw e;
}
}

private void validate(PlanNode plan)
{
plan.accept(new PlanVisitor<Set<DynamicFilterId>, Void>()
{
Expand Down

0 comments on commit ca48ae4

Please sign in to comment.