Skip to content

Commit

Permalink
fix: Fix align_frames with single row panicking (#20466)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemanley authored Dec 27, 2024
1 parent 0c290d6 commit 4c5fc38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/polars-ops/src/frame/join/dispatch_left_right.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ fn maintain_order_idx(
let join_tuples_left = df
.column("a")
.unwrap()
.as_series()
.unwrap()
.as_materialized_series()
.idx()
.unwrap()
.cont_slice()
Expand All @@ -180,8 +179,7 @@ fn maintain_order_idx(
let join_tuples_right = df
.column("b")
.unwrap()
.as_series()
.unwrap()
.as_materialized_series()
.idx()
.unwrap()
.cont_slice()
Expand Down
8 changes: 8 additions & 0 deletions py-polars/tests/unit/functions/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,14 @@ def test_align_frames_duplicate_key() -> None:
]


def test_align_frames_single_row_20445() -> None:
left = pl.DataFrame({"a": [1], "b": [2]})
right = pl.DataFrame({"a": [1], "c": [3]})
result = pl.align_frames(left, right, how="left", on="a")
assert_frame_equal(result[0], left)
assert_frame_equal(result[1], right)


def test_coalesce() -> None:
df = pl.DataFrame(
{
Expand Down

0 comments on commit 4c5fc38

Please sign in to comment.