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

Lazy select(len()) fails after unique() on first column #21154

Closed
2 tasks done
guyrosin opened this issue Feb 9, 2025 · 2 comments · Fixed by #21162
Closed
2 tasks done

Lazy select(len()) fails after unique() on first column #21154

guyrosin opened this issue Feb 9, 2025 · 2 comments · Fixed by #21162
Assignees
Labels
A-optimizer Area: plan optimization accepted Ready for implementation bug Something isn't working P-high Priority: high python Related to Python Polars regression Issue introduced by a new release

Comments

@guyrosin
Copy link

guyrosin commented Feb 9, 2025

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

lf = pl.LazyFrame({"a":[1,2,3], "b": [4,5,6]})

lf.unique("a").select(pl.len()).collect()  # <-- fails

lf.unique("b").select(pl.len()).collect()  # <-- succeeds
lf.unique().select(pl.len()).collect()  # <-- succeeds

Log output

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/guy/code/playground/.venv/lib/python3.13/site-packages/polars/lazyframe/frame.py", line 2066, in collect
    return wrap_df(ldf.collect(callback))
                   ~~~~~~~~~~~^^^^^^^^^^
polars.exceptions.ColumnNotFoundError: "a" not found

Issue description

This seems like a regression in polars 1.22.0

Expected behavior

The code should output the frame's length

shape: (1, 1)
┌─────┐
│ len │
│ --- │
│ u32 │
╞═════╡
│ 3   │
└─────┘

Installed versions

--------Version info---------
Polars:              1.22.0
Index type:          UInt32
Platform:            macOS-15.3-arm64-arm-64bit-Mach-O
Python:              3.13.0 (main, Oct  7 2024, 23:47:22) [Clang 18.1.8 ]
LTS CPU:             False

----Optional dependencies----
Azure CLI            <not installed>
adbc_driver_manager  <not installed>
altair               5.5.0
azure.identity       <not installed>
boto3                1.35.93
cloudpickle          3.1.1
connectorx           <not installed>
deltalake            <not installed>
fastexcel            0.12.1
fsspec               2025.2.0
gevent               <not installed>
google.auth          2.38.0
great_tables         <not installed>
matplotlib           3.10.0
numpy                2.1.3
openpyxl             <not installed>
pandas               2.2.3
pyarrow              19.0.0
pydantic             2.10.6
pyiceberg            <not installed>
sqlalchemy           2.0.38
torch                2.6.0
xlsx2csv             0.8.4
xlsxwriter           3.2.2
@guyrosin guyrosin added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Feb 9, 2025
@nameexhaustion nameexhaustion added regression Issue introduced by a new release accepted Ready for implementation P-medium Priority: medium A-optimizer Area: plan optimization rust Related to Rust Polars and removed needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars labels Feb 10, 2025
@nameexhaustion
Copy link
Collaborator

@nameexhaustion nameexhaustion added P-high Priority: high and removed P-medium Priority: medium labels Feb 10, 2025
@ritchie46 ritchie46 self-assigned this Feb 10, 2025
@ritchie46
Copy link
Member

Fix incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-optimizer Area: plan optimization accepted Ready for implementation bug Something isn't working P-high Priority: high python Related to Python Polars regression Issue introduced by a new release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants