Skip to content

Commit

Permalink
fix[rust]: rolling_max no_null dispatch (#4442)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Aug 16, 2022
1 parent fdfb001 commit c171634
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions polars/polars-time/src/chunkedarray/rolling_window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ where
check_input(options.window_size, options.min_periods)?;
let ca = ca.rechunk();

match ca.has_validity() {
false => rolling_agg_fn(
match ca.null_count() {
0 => rolling_agg_fn(
arr.values().as_slice(),
options.window_size,
options.min_periods,
Expand Down
30 changes: 30 additions & 0 deletions py-polars/tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,33 @@ def test_edge_cast_string_duplicates_4259() -> None:

mask = df.select(["a", "b"]).is_duplicated()
assert df.filter(pl.lit(mask)).shape == (0, 2)


def test_query_4438() -> None:
df = pl.DataFrame({"x": [1, 2, 3, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1]})

q = (
df.lazy()
.with_column(pl.col("x").rolling_max(window_size=3).alias("rolling_max"))
.fill_null(strategy="backward")
.with_column(
pl.col("rolling_max").rolling_max(window_size=3).alias("rolling_max_2")
)
)
assert q.collect()["rolling_max_2"].to_list() == [
None,
None,
3,
10,
10,
10,
10,
10,
9,
8,
7,
6,
5,
4,
3,
]

0 comments on commit c171634

Please sign in to comment.