From 6e4d7170dc33dc0e76d50ec221ef368afc32070d Mon Sep 17 00:00:00 2001 From: nameexhaustion Date: Wed, 18 Dec 2024 19:19:18 +1100 Subject: [PATCH] test(python): Add test for `select(len())` (#20343) --- py-polars/tests/unit/test_projections.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/py-polars/tests/unit/test_projections.py b/py-polars/tests/unit/test_projections.py index 95b4ad1ef535..f395bee590ea 100644 --- a/py-polars/tests/unit/test_projections.py +++ b/py-polars/tests/unit/test_projections.py @@ -618,3 +618,15 @@ def test_with_columns_projection_pushdown() -> None: def test_projection_pushdown_height_20221() -> None: q = pl.LazyFrame({"a": range(5)}).select("a", b=pl.col("a").first()).select("b") assert_frame_equal(q.collect(), pl.DataFrame({"b": [0, 0, 0, 0, 0]})) + + +def test_select_len_20337() -> None: + strs = [str(i) for i in range(3)] + q = pl.LazyFrame({"a": strs, "b": strs, "c": strs, "d": range(3)}) + + q = q.group_by(pl.col("c")).agg( + (pl.col("d") * j).alias(f"mult {j}") for j in [1, 2] + ) + + q = q.with_row_index("foo") + assert q.select(pl.len()).collect().item() == 3