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

SNOW-1356685: Fix precision loss bug in DataFrame/Series with dtype=np.uint64 #1777

Merged
merged 3 commits into from
Jun 20, 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Fixed a bug where python stored procedure with table return type fails when run in a task.
- Fixed a bug where df.dropna fails due to `RecursionError: maximum recursion depth exceeded` when the DataFrame has more than 500 columns.
- Fixed a bug where `AsyncJob.result("no_result")` doesn't wait for the query to finish execution.
- Fixed a bug regarding precision loss when converting to Snowpark pandas `DataFrame` or `Series` with `dtype=np.uint64`.

### Snowpark Local Testing Updates

Expand Down Expand Up @@ -50,6 +51,7 @@
- Fixed a bug that causes output of GroupBy.aggregate's columns to be ordered incorrectly.
- Fixed a bug where `DataFrame.describe` on a frame with duplicate columns of differing dtypes could cause an error or incorrect results.
- Fixed a bug in `DataFrame.rolling` and `Series.rolling` so `window=0` now throws `NotImplementedError` instead of `ValueError`
- Fixed a bug in `DataFrame` and `Series` with `dtype=np.uint64` resulting in precision errors

#### Improvements

Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/snowpark/_internal/server_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ def _fix_pandas_df_fixed_type(
pd_df[pandas_col_name] = pd_df[pandas_col_name].astype("int64")
except OverflowError:
pd_df[pandas_col_name] = pandas.to_numeric(
pd_df[pandas_col_name], downcast="integer"
pd_df[pandas_col_name]
)
else:
pd_df[pandas_col_name] = pandas.to_numeric(
Expand Down
14 changes: 11 additions & 3 deletions tests/integ/modin/series/test_unique.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#
from decimal import Decimal
from typing import Any

import modin.pandas as pd
Expand All @@ -26,13 +27,20 @@ def _make_nan_interleaved_float_series():
[12.0, 11.999999, 11.999999],
["A", "A", "C", "C", "A"],
[None, "A", None, "B"],
_make_nan_interleaved_float_series(),
native_pd.Series([1, 2, 2**63, 2**63], dtype=np.uint64),
pytest.param(
native_pd.Series([1, 2, 2**63, 2**63], dtype=np.uint64),
native_pd.Series([1, 2, -(2**63) - 1, -(2**64)]),
marks=pytest.mark.xfail(
reason="SNOW-1356685: Dtype with unsigned int results in precision error"
reason="Represent overflow using float instead of integer",
),
),
pytest.param(
native_pd.Series([Decimal(1.5), Decimal(2**64 - 1)], dtype=object),
marks=pytest.mark.xfail(
reason="Represent Decimal using float instead of integer as pandas does not recognize it",
),
),
_make_nan_interleaved_float_series(),
]


Expand Down
Loading