Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix ColumnNotFound error selecting len() after semi/anti join #21355

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading