Skip to content
Merged
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 @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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<PlanNode> 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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to also check that the filter matches?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, the filter match will be checked by the following assertPlan. As long as filterNode is present, it will check.

hasFilterNode = true;
break;
}
}
assertTrue(hasFilterNode, "filter is missing from the pushdown plan");

PlanAssert.assertPlan(
TEST_SESSION,
METADATA,
Expand Down