diff --git a/presto-base-jdbc/src/test/java/com/facebook/presto/plugin/jdbc/optimization/TestJdbcComputePushdown.java b/presto-base-jdbc/src/test/java/com/facebook/presto/plugin/jdbc/optimization/TestJdbcComputePushdown.java index 8cd4629de6fd2..a9ed5ae53d341 100644 --- a/presto-base-jdbc/src/test/java/com/facebook/presto/plugin/jdbc/optimization/TestJdbcComputePushdown.java +++ b/presto-base-jdbc/src/test/java/com/facebook/presto/plugin/jdbc/optimization/TestJdbcComputePushdown.java @@ -63,7 +63,9 @@ import java.sql.Types; import java.util.Arrays; +import java.util.LinkedList; import java.util.Optional; +import java.util.Queue; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -78,6 +80,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static java.util.function.Function.identity; import static java.util.stream.Collectors.toMap; +import static org.testng.Assert.assertTrue; public class TestJdbcComputePushdown { @@ -259,6 +262,22 @@ private static void assertPlanMatch(PlanNode actual, PlanMatchPattern expected) private static void assertPlanMatch(PlanNode actual, PlanMatchPattern expected, TypeProvider typeProvider) { + // always check the actual plan node has a filter node to prevent accidentally missing predicates + Queue nodes = new LinkedList<>(ImmutableSet.of(actual)); + boolean hasFilterNode = false; + while (!nodes.isEmpty()) { + PlanNode node = nodes.poll(); + nodes.addAll(node.getSources()); + + // we always enforce the original filter to be present + // the following assertPlan will guarantee the completeness of the filter + if (node instanceof FilterNode && node.getSources().get(0) instanceof TableScanNode) { + hasFilterNode = true; + break; + } + } + assertTrue(hasFilterNode, "filter is missing from the pushdown plan"); + PlanAssert.assertPlan( TEST_SESSION, METADATA,