[SPARK-54938][PYTHON][TEST][FOLLOW-UP] Fix inferred time unit for ns Timestamp/Timedelta under pandas 3#57070
Closed
fangchenli wants to merge 1 commit into
Closed
Conversation
…Timestamp/Timedelta sentinels under pandas 3
### What changes were proposed in this pull request?
In `test_pandas_series_numpy_backed`, expect nanosecond resolution for the
`pd.Timestamp.min` / `pd.Timestamp.max` and `pd.Timedelta(0)` / `.min` / `.max`
cases instead of following the pandas-3 `us` default used for the other
temporal cases.
### Why are the changes needed?
The pandas >= 3 handling added in SPARK-54938 assumed pandas 3 defaults every
temporal Series to microsecond resolution. That holds for parsed values
(`pd.to_datetime`, `pd.to_timedelta`, `pd.Timestamp("1970-01-01")`), but
`pd.Timestamp.min` / `pd.Timestamp.max` carry nanosecond precision and
`pd.Timedelta(0)` / `.min` / `.max` are constructed at nanosecond resolution,
so `pa.array()` infers `timestamp[ns]` / `duration[ns]` for them under pandas 3
as well. The blanket `us` expectation made the test fail under pandas 3
(`timestamp[ns] != timestamp[us]`). These cases are `ns` under both pandas 2 and
pandas 3.
### Does this PR introduce _any_ user-facing change?
No, test-only.
### How was this patch tested?
`test_pyarrow_array_type_inference` passes under pandas 3 + pyarrow 23 and under
pandas 2 + pyarrow 22.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
|
Sorry I had to merge this first. Fixed by 7ca3cc3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
In
test_pandas_series_numpy_backed, expect nanosecond resolution for thepd.Timestamp.min/pd.Timestamp.maxandpd.Timedelta(0)/.min/.maxcases instead of following the pandas-3usdefault used for the other temporal cases.Why are the changes needed?
Align with pandas 3.
Does this PR introduce any user-facing change?
No, test-only.
How was this patch tested?
test_pyarrow_array_type_inferencepasses under pandas 3 + pyarrow 23 and under pandas 2 + pyarrow 22.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8