Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Nov 27, 2023
1 parent c53acca commit 6a62d57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ impl<'a> PredicatePushDown<'a> {

let local_predicates = match eligibility {
PushdownEligibility::Full => vec![],
PushdownEligibility::Partial(allowed) => {
let mut out = Vec::<Node>::with_capacity(allowed.len());
for key in allowed {
PushdownEligibility::Partial(to_local) => {
let mut out = Vec::<Node>::with_capacity(to_local.len());
for key in to_local {
out.push(acc_predicates.remove(&key).unwrap());
}
out
Expand Down Expand Up @@ -256,9 +256,9 @@ impl<'a> PredicatePushDown<'a> {

let local_predicates = match pushdown_eligibility(lp.schema(lp_arena).as_ref(), &vec![], &acc_predicates, expr_arena)?.0 {
PushdownEligibility::Full => vec![],
PushdownEligibility::Partial(allowed) => {
let mut out = Vec::<Node>::with_capacity(allowed.len());
for key in allowed {
PushdownEligibility::Partial(to_local) => {
let mut out = Vec::<Node>::with_capacity(to_local.len());
for key in to_local {
out.push(acc_predicates.remove(&key).unwrap());
}
out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ pub fn pushdown_eligibility(
}
};

let allowed_predicates = acc_predicates
let to_local = acc_predicates
.iter()
.filter_map(|(key, &node)| {
debug_assert!(ae_nodes_stack.is_empty());
Expand All @@ -447,21 +447,20 @@ pub fn pushdown_eligibility(

ae_nodes_stack.clear();

if can_pushdown {
if !can_pushdown {
Some(key.clone())
} else {
None
}
})
.collect::<Vec<_>>();

match allowed_predicates.len() {
0 => Ok((PushdownEligibility::NoPushdown, alias_to_col_map)),
len if len == acc_predicates.len() => Ok((PushdownEligibility::Full, alias_to_col_map)),
_ => Ok((
PushdownEligibility::Partial(allowed_predicates),
alias_to_col_map,
)),
match to_local.len() {
0 => Ok((PushdownEligibility::Full, alias_to_col_map)),
len if len == acc_predicates.len() => {
Ok((PushdownEligibility::NoPushdown, alias_to_col_map))
},
_ => Ok((PushdownEligibility::Partial(to_local), alias_to_col_map)),
}
}

Expand Down
1 change: 1 addition & 0 deletions py-polars/tests/unit/test_predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def test_predicate_pushdown_with_window_projections_12637() -> None:
)

plan = actual.explain()
print(plan)
assert "FILTER" in plan
assert r'SELECTION: "[(col(\"key\")) == (5)]"' in plan

Expand Down

0 comments on commit 6a62d57

Please sign in to comment.