zhengruifeng opened a new pull request, #57076:
URL: https://github.com/apache/spark/pull/57076
### What changes were proposed in this pull request?
Fix an incorrect pandas-3 resolution assumption in
`test_pandas_series_numpy_backed` (in
`test_pyarrow_array_type_inference.py`).
The test used a single `ts_unit = "us" if pandas >= 3 else "ns"` for all
numpy-backed temporal cases. Empirically, pandas 3 only produces microsecond
resolution for parse/construct/tz-aware inputs (`pd.to_datetime`,
`pd.Timestamp("...")`, `pd.to_timedelta`, tz-aware Series). The boundary
constants `pd.Timestamp.min/max` and `pd.Timedelta.min/max`, and the
`pd.Timedelta(0)` scalar, remain nanosecond-backed in both pandas 2 and 3,
because those values only fit in nanosecond resolution.
This PR pins those boundary/scalar cases to `"ns"` and keeps `ts_unit` for
the remaining cases, and clarifies the comment.
### Why are the changes needed?
The scheduled `Build / Python-only (Python 3.12, Pandas 3)` job fails on
master:
```
File ".../test_pyarrow_array_type_inference.py", line 348, in
test_pandas_series_numpy_backed
self._run_inference_tests(cases)
AssertionError: TimestampType(timestamp[ns]) != TimestampType(timestamp[us])
```
The test loop stops at the first mismatch (`pd.Timestamp.min`), which is why
only one failure surfaced. The wrong branch was never exercised until the
Pandas-3 job ran.
### Does this PR introduce _any_ user-facing change?
No. Test-only change.
### How was this patch tested?
Ran the suite in two local conda environments (with `SPARK_TESTING=1`):
- pandas 3.0.2 / pyarrow 23.0.1: 10/10 pass
- pandas 2.3.3: 10/10 pass (no regression)
`ruff format --check` and `ruff check` both pass on the changed file.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]