Skip to content

Commit

Permalink
fix: Fix ColumnNotFound error selecting len() after semi/anti join (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion authored Feb 20, 2025
1 parent 53f0bfd commit 42104e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions py-polars/tests/unit/operations/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 42104e2

Please sign in to comment.