Skip to content

Commit 79e68b7

Browse files
committed
rename func to updateFilterNode
1 parent a27ceb5 commit 79e68b7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sql/analyzer/pushdown.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func pushFilters(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope, s
9696
return n, transform.SameTree, fmt.Errorf("pushdown mistakenly converted filter to non-filter: %T", ret)
9797
}
9898
// remove handled
99-
newF := removePushedDownPredicates(ctx, a, retF, filters)
99+
newF := updateFilterNode(ctx, a, retF, filters)
100100
if newF != nil {
101101
same = transform.NewTree
102102
ret = newF
@@ -202,7 +202,7 @@ func transformPushdownSubqueryAliasFilters(ctx *sql.Context, a *Analyzer, n sql.
202202
return transform.NodeWithCtx(n, filterPushdownChildSelector, func(c transform.Context) (sql.Node, transform.TreeIdentity, error) {
203203
switch node := c.Node.(type) {
204204
case *plan.Filter:
205-
newF := removePushedDownPredicates(ctx, a, node, filters)
205+
newF := updateFilterNode(ctx, a, node, filters)
206206
if newF == nil {
207207
return node, transform.SameTree, nil
208208
}
@@ -311,9 +311,12 @@ func pushdownFiltersUnderSubqueryAlias(ctx *sql.Context, a *Analyzer, sa *plan.S
311311
return n, transform.NewTree, nil
312312
}
313313

314-
// removePushedDownPredicates removes all handled filter predicates from the filter given and returns. If all
315-
// predicates have been handled, it replaces the filter with its child.
316-
func removePushedDownPredicates(ctx *sql.Context, a *Analyzer, node *plan.Filter, filters *filterSet) sql.Node {
314+
// updateFilterNode updates the filter node based on the filter predicates handled. Any handled filter predicates are
315+
// removed from the filter node. If all filter predicates have been handled and there are no unhandled predicates, the
316+
// filter node is removed. If there are remaining filter predicates and the immediate child of the filter is a non-outer
317+
// join, the remaining unhandled filters are pushed into the join node and added to the join filters, and the filter
318+
// node is removed.
319+
func updateFilterNode(ctx *sql.Context, a *Analyzer, node *plan.Filter, filters *filterSet) sql.Node {
317320
filterExpressions := expression.SplitConjunction(node.Expression)
318321
unhandled := subtractExprSet(filterExpressions, filters.handledFilters)
319322

0 commit comments

Comments
 (0)