Skip to content

[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
apache:masterfrom
fangchenli:pandas3-fix-pyarrow-tsunit
Closed

[SPARK-54938][PYTHON][TEST][FOLLOW-UP] Fix inferred time unit for ns Timestamp/Timedelta under pandas 3#57070
fangchenli wants to merge 1 commit into
apache:masterfrom
fangchenli:pandas3-fix-pyarrow-tsunit

Conversation

@fangchenli

Copy link
Copy Markdown
Contributor

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?

Align with 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

…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>
@HyukjinKwon

Copy link
Copy Markdown
Member

Sorry I had to merge this first. Fixed by 7ca3cc3

@HyukjinKwon HyukjinKwon closed this Jul 8, 2026
@fangchenli fangchenli deleted the pandas3-fix-pyarrow-tsunit branch July 8, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants