Skip to content

Commit 01fadd9

Browse files
fix: Fix incorrect lazy select(len()) with some select orderings (#20222)
1 parent 4163fd3 commit 01fadd9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crates/polars-plan/src/plans/optimizer/projection_pushdown/projection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ pub(super) fn process_projection(
7171
} else {
7272
// Select the last column projection.
7373
let mut name = None;
74-
for (_, plan) in (&*lp_arena).iter(input) {
74+
'outer: for (_, plan) in (&*lp_arena).iter(input) {
7575
match plan {
7676
IR::Select { expr: exprs, .. } | IR::HStack { exprs, .. } => {
7777
for e in exprs {
7878
if !e.is_scalar(expr_arena) {
7979
name = Some(e.output_name());
80-
break;
80+
break 'outer;
8181
}
8282
}
8383
},

py-polars/tests/unit/test_scalar.py

+7
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ def test_scalar_len_20046() -> None:
6363
.item()
6464
== 3
6565
)
66+
67+
q = pl.LazyFrame({"a": range(3)}).select(
68+
pl.first("a"),
69+
pl.col("a").alias("b"),
70+
)
71+
72+
assert q.select(pl.len()).collect().item() == 3

0 commit comments

Comments
 (0)