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

fix: Fix Expr.over applying scale incorrectly for Decimal types #21140

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/polars-expr/src/expressions/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ fn set_by_groups(
}};
}
downcast_as_macro_arg_physical!(&s, dispatch)
.map(|s| s.cast(dtype).unwrap())
.map(|s| unsafe { s.from_physical_unchecked(dtype) }.unwrap())
.map(Column::from)
} else {
None
Expand Down
6 changes: 6 additions & 0 deletions py-polars/tests/unit/datatypes/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,3 +712,9 @@ def test_cast_float_to_decimal_12775() -> None:
# default scale = 0
assert s.cast(pl.Decimal).to_list() == [D("1")]
assert s.cast(pl.Decimal(scale=1)).to_list() == [D("1.5")]


def test_decimal_min_over_21096() -> None:
df = pl.Series("x", [1, 2], pl.Decimal(scale=2)).to_frame()
result = df.select(pl.col("x").min().over("x"))
assert result["x"].to_list() == [D("1.00"), D("2.00")]
Loading