Skip to content

Commit

Permalink
fix: Fix comparison of UInt64 with zero
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Jun 7, 2024
1 parent efac81c commit b7bdb29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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() {
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

0 comments on commit b7bdb29

Please sign in to comment.