Skip to content

Commit

Permalink
Fix expression predicate pushdown not firing before AddExchanges
Browse files Browse the repository at this point in the history
Before the change, the pushdown of `ConnectorExpression` was fired only
when
- there was some other `TupleDomain` constraint to be pushed down, OR
- during `AddExchanges`, because functional predicate is created there.

This commit enables expression-based pushdown early, allowing further
pushdowns -- like aggregation or join pushdown -- to happen. These need
to happen before `AddExchanges`.
  • Loading branch information
findepi committed Mar 11, 2022
1 parent a8f1d67 commit 70c988b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ public static Optional<PlanNode> pushFilterIntoTableScan(
}

// check if new domain is wider than domain already provided by table scan
if (constraint.predicate().isEmpty() && newDomain.contains(node.getEnforcedConstraint())) {
if (constraint.predicate().isEmpty() &&
// TODO do we need to track enforced ConnectorExpression in TableScanNode?
TRUE.equals(connectorExpression.orElse(TRUE)) &&
newDomain.contains(node.getEnforcedConstraint())) {
Expression resultingPredicate = createResultingPredicate(
plannerContext,
session,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,8 @@ public void testAggregationPushdown()
assertConditionallyPushedDown(
getSession(),
"SELECT regionkey, sum(nationkey) FROM nation WHERE name LIKE '%N%' GROUP BY regionkey",
false, // TODO: hasBehavior(SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN_WITH_LIKE), -- currently, applyAggregation is not invoked after applyFilter with expression
hasBehavior(SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN_WITH_LIKE)
? node(AggregationNode.class, node(TableScanNode.class))
: node(FilterNode.class, node(TableScanNode.class)));
hasBehavior(SUPPORTS_PREDICATE_EXPRESSION_PUSHDOWN_WITH_LIKE),
node(FilterNode.class, node(TableScanNode.class)));
// aggregation on varchar column
assertThat(query("SELECT count(name) FROM nation")).isFullyPushedDown();
// aggregation on varchar column with GROUPING
Expand Down

0 comments on commit 70c988b

Please sign in to comment.