Skip to content

Commit

Permalink
fix: Fix gather of Scalar null + idx w/ validity (#19823)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Nov 16, 2024
1 parent 7482315 commit 9311cdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/polars-core/src/frame/column/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl Column {
);

// We need to make sure that null values in `idx` become null values in the result
if idxs_null_count == 0 {
if idxs_null_count == 0 || scalar.has_nulls() {
scalar.into_column()
} else if idxs_null_count == idxs_length {
scalar.into_nulls().into_column()
Expand Down
10 changes: 10 additions & 0 deletions py-polars/tests/unit/operations/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,3 +1123,13 @@ def test_array_explode_join_19763() -> None:
q = q.join(pl.LazyFrame({"k": [1, 2]}), on="k")

assert_frame_equal(q.collect().sort("k"), pl.DataFrame({"k": [1, 2]}))


def test_join_full_19814() -> None:
a = pl.LazyFrame(
{"a": [1], "c": [None]}, schema={"a": pl.Int64, "c": pl.Categorical}
)
b = pl.LazyFrame({"a": [1, 3, 4]})
assert a.join(b, on="a", how="full", coalesce=True).collect().to_dict(
as_series=False
) == {"a": [1, 3, 4], "c": [None, None, None]}

0 comments on commit 9311cdd

Please sign in to comment.