Skip to content

Commit

Permalink
fix: Fix incorrect lazy select(len()) with some select orderings (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion authored Dec 9, 2024
1 parent 4163fd3 commit 01fadd9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ pub(super) fn process_projection(
} else {
// Select the last column projection.
let mut name = None;
for (_, plan) in (&*lp_arena).iter(input) {
'outer: for (_, plan) in (&*lp_arena).iter(input) {
match plan {
IR::Select { expr: exprs, .. } | IR::HStack { exprs, .. } => {
for e in exprs {
if !e.is_scalar(expr_arena) {
name = Some(e.output_name());
break;
break 'outer;
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions py-polars/tests/unit/test_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ def test_scalar_len_20046() -> None:
.item()
== 3
)

q = pl.LazyFrame({"a": range(3)}).select(
pl.first("a"),
pl.col("a").alias("b"),
)

assert q.select(pl.len()).collect().item() == 3

0 comments on commit 01fadd9

Please sign in to comment.