Skip to content

Commit

Permalink
fix: maintain old join behavior in window expression (#13179)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Dec 21, 2023
1 parent 5e3ffd2 commit d664e44
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/polars-lazy/src/physical_plan/expressions/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ impl PhysicalExpr for WindowExpr {
let df_right = DataFrame::new_no_checks(keys);
let df_left = DataFrame::new_no_checks(group_by_columns);
private_left_join_multiple_keys(
&df_left, &df_right, None, None, false,
&df_left, &df_right, None, None, true,
)
.1
}
Expand Down
18 changes: 18 additions & 0 deletions py-polars/tests/unit/operations/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,21 @@ def test_window_10417() -> None:
pl.col("c") - pl.col("c").mean().over("a"),
]
).collect().to_dict(as_series=False) == {"a": [1], "b": [0.0], "c": [0.0]}


def test_window_13173() -> None:
df = pl.DataFrame(
data={
"color": ["yellow", "yellow"],
"color2": [None, "light"],
"val": ["2", "3"],
}
)
assert df.with_columns(
pl.min("val").over(["color", "color2"]).alias("min_val_per_color")
).to_dict(as_series=False) == {
"color": ["yellow", "yellow"],
"color2": [None, "light"],
"val": ["2", "3"],
"min_val_per_color": ["2", "3"],
}

0 comments on commit d664e44

Please sign in to comment.