From 9bcbe7dab351d9fc5d4cd2c0dd26f52ffebe708a Mon Sep 17 00:00:00 2001 From: Simon Lin Date: Thu, 20 Feb 2025 17:37:54 +1100 Subject: [PATCH] c --- .../optimizer/projection_pushdown/semi_anti_join.rs | 2 +- py-polars/tests/unit/operations/test_join.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/polars-plan/src/plans/optimizer/projection_pushdown/semi_anti_join.rs b/crates/polars-plan/src/plans/optimizer/projection_pushdown/semi_anti_join.rs index 419f75695a17..607e0db2597e 100644 --- a/crates/polars-plan/src/plans/optimizer/projection_pushdown/semi_anti_join.rs +++ b/crates/polars-plan/src/plans/optimizer/projection_pushdown/semi_anti_join.rs @@ -19,7 +19,7 @@ pub(super) fn process_semi_anti_join( let mut names_left = PlHashSet::with_capacity(n); let mut names_right = PlHashSet::with_capacity(n); - if ctx.acc_projections.is_empty() { + if !ctx.has_pushed_down() { // Only project the join columns. for e in &right_on { add_expr_to_accumulated(e.node(), &mut pushdown_right, &mut names_right, expr_arena); diff --git a/py-polars/tests/unit/operations/test_join.py b/py-polars/tests/unit/operations/test_join.py index 761b90c82c78..88d91c7105fd 100644 --- a/py-polars/tests/unit/operations/test_join.py +++ b/py-polars/tests/unit/operations/test_join.py @@ -1800,3 +1800,12 @@ def time_func(func: Callable[[], Any]) -> float: if runtime_ratio > threshold: msg = f"runtime_ratio ({runtime_ratio}) > {threshold}x ({runtime_eager = }, {runtime_lazy = })" raise ValueError(msg) + + +def test_select_len_after_semi_anti_join_21343() -> None: + lhs = pl.LazyFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) + rhs = pl.LazyFrame({"a": [1, 2, 3]}) + + q = lhs.join(rhs, on="a", how="anti").select(pl.len()) + + assert q.collect().item() == 0