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

align_frames regression: 1-row inputs with how="left" triggers panic #20445

Closed
2 tasks done
rcliu623 opened this issue Dec 24, 2024 · 0 comments · Fixed by #20466
Closed
2 tasks done

align_frames regression: 1-row inputs with how="left" triggers panic #20445

rcliu623 opened this issue Dec 24, 2024 · 0 comments · Fixed by #20466
Labels
A-panic Area: code that results in panic exceptions bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@rcliu623
Copy link

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

raw_dict = {"_grouping_id": [1], "a": [0], "b": [2]}
df = pl.DataFrame(raw_dict)
print(pl.align_frames(df, df, how="full", on="_grouping_id"))
print(pl.align_frames(df, df, how="left", on="_grouping_id"))

Log output

join parallel: true
join parallel: true
FULL join dataframes finished
FULL join dataframes finished
[shape: (1, 3)
┌──────────────┬─────┬─────┐
│ _grouping_id ┆ a   ┆ b   │
│ ---          ┆ --- ┆ --- │
│ i64          ┆ i64 ┆ i64 │
╞══════════════╪═════╪═════╡
│ 1            ┆ 0   ┆ 2   │
└──────────────┴─────┴─────┘, shape: (1, 3)
┌──────────────┬─────┬─────┐
│ _grouping_id ┆ a   ┆ b   │
│ ---          ┆ --- ┆ --- │
│ i64          ┆ i64 ┆ i64 │
╞══════════════╪═════╪═════╡
│ 1            ┆ 0   ┆ 2   │
└──────────────┴─────┴─────┘]
join parallel: true
left join: keys are sorted: use sorted merge join
join parallel: true
left join: keys are sorted: use sorted merge join
thread 'polars-0' panicked at crates/polars-ops/src/frame/join/dispatch_left_right.rs:174:10:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'polars-1' panicked at crates/polars-ops/src/frame/join/dispatch_left_right.rs:174:10:
called `Option::unwrap()` on a `None` value
Traceback (most recent call last):
  File "/home/polars_regression.py", line 7, in <module>
    print(pl.align_frames(df, df, how="left", on="_grouping_id"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.conda/lib/python3.11/site-packages/polars/functions/eager.py", line 475, in align_frames
    return F.collect_all(aligned_frames) if eager else aligned_frames  # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.conda/lib/python3.11/site-packages/polars/functions/lazy.py", line 1714, in collect_all
    out = plr.collect_all(prepared)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value

Issue description

In 1.18, invoking align_frames with how="left" on 1-row dataframes now triggers a panic. Such error did not exist <=1.17.

Expected behavior

pl.align_frames(df, df, how="left", on="_grouping_id") should work as intended

Installed versions

--------Version info---------
Polars:              1.18.0
Index type:          UInt32
Platform:            Linux-4.18.0-477.36.1.x86_64-x86_64-with-glibc2.28
Python:              3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0]
LTS CPU:             False

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
azure.identity       <not installed>
boto3                <not installed>
cloudpickle          3.1.0
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               2024.10.0
gevent               <not installed>
google.auth          <not installed>
great_tables         <not installed>
matplotlib           3.9.2
nest_asyncio         1.6.0
numpy                1.25.0
openpyxl             <not installed>
pandas               2.1.4
pyarrow              18.0.0
pydantic             2.9.2
pyiceberg            <not installed>
sqlalchemy           2.0.36
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>
@rcliu623 rcliu623 added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Dec 24, 2024
@alexander-beedie alexander-beedie added the A-panic Area: code that results in panic exceptions label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-panic Area: code that results in panic exceptions bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants