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 comparison of UInt64 with zero #16799

Merged
merged 1 commit into from
Jun 7, 2024
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-core/src/utils/supertype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ pub fn get_supertype(l: &DataType, r: &DataType) -> Option<DataType> {
}
// dyn int vs number
else {
let smallest_fitting_dtype = if dt.is_unsigned_integer() && v.is_positive() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue was here, is_positive doesn't include zero

let smallest_fitting_dtype = if dt.is_unsigned_integer() && !v.is_negative() {
materialize_dyn_int_pos(*v).dtype()
} else {
materialize_smallest_dyn_int(*v).dtype()
Expand Down
6 changes: 6 additions & 0 deletions py-polars/tests/unit/datatypes/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ def test_int_negate_operation() -> None:
-5,
-50912341410,
]


def test_compare_zero_with_uint64_16798() -> None:
df = pl.Series("a", [(1 << 63), 0], dtype=pl.UInt64).to_frame()
assert df.select(pl.col("a") >= 0).item(0, 0)
assert df.select(pl.col("a") == 0).item(0, 0) is False
Loading