From 72cc7e5f51c334674b01768a425824e1152e4785 Mon Sep 17 00:00:00 2001 From: Anas Khan <83116240+anxkhn@users.noreply.github.com> Date: Mon, 27 Jul 2026 23:18:42 +0530 Subject: [PATCH 1/2] GH-50530: [Python] Assert assume_timezone results at input precision Assert the existing nonexistent and ambiguous time comparisons so regressions cannot pass unnoticed. Construct expected arrays from the input timestamp unit and requested timezone to preserve precision across pandas versions without masking output-type regressions. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> --- python/pyarrow/tests/test_compute.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index 1e08e73668e5..f7fcb8a4e06a 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -2797,17 +2797,18 @@ def test_assume_timezone(): pc.assume_timezone(nonexistent_array, options=options_nonexistent_raise) - expected = pa.array(nonexistent.tz_localize( - timezone, nonexistent="shift_forward")) result = pc.assume_timezone( nonexistent_array, options=options_nonexistent_latest) - expected.equals(result) - + expected_type = pa.timestamp(nonexistent_array.type.unit, tz=timezone) expected = pa.array(nonexistent.tz_localize( - timezone, nonexistent="shift_backward")) + timezone, nonexistent="shift_forward"), type=expected_type) + assert expected.equals(result) + result = pc.assume_timezone( nonexistent_array, options=options_nonexistent_earliest) - expected.equals(result) + expected = pa.array(nonexistent.tz_localize( + timezone, nonexistent="shift_backward"), type=expected_type) + assert expected.equals(result) options_ambiguous_raise = pc.AssumeTimezoneOptions(timezone) options_ambiguous_latest = pc.AssumeTimezoneOptions( @@ -2820,15 +2821,18 @@ def test_assume_timezone(): f"timezone '{timezone}'"): pc.assume_timezone(ambiguous_array, options=options_ambiguous_raise) - expected = ambiguous.tz_localize(timezone, ambiguous=[True, True, True]) result = pc.assume_timezone( ambiguous_array, options=options_ambiguous_earliest) - result.equals(pa.array(expected)) + expected_type = pa.timestamp(ambiguous_array.type.unit, tz=timezone) + expected = pa.array(ambiguous.tz_localize( + timezone, ambiguous=[True, True, True]), type=expected_type) + assert result.equals(expected) - expected = ambiguous.tz_localize(timezone, ambiguous=[False, False, False]) result = pc.assume_timezone( ambiguous_array, options=options_ambiguous_latest) - result.equals(pa.array(expected)) + expected = pa.array(ambiguous.tz_localize( + timezone, ambiguous=[False, False, False]), type=expected_type) + assert result.equals(expected) def _check_temporal_rounding(ts, values, unit): From a104cd455bab7ff1fa63bd8fe283872dd1648804 Mon Sep 17 00:00:00 2001 From: Anas Khan <83116240+anxkhn@users.noreply.github.com> Date: Tue, 28 Jul 2026 00:08:59 +0530 Subject: [PATCH 2/2] GH-50530: [Python] Pin DST fixture to nanoseconds Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> --- python/pyarrow/tests/test_compute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index f7fcb8a4e06a..aa455574afb0 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -2757,7 +2757,7 @@ def test_assume_timezone(): "2008-12-29T00:00:00.0", "2012-01-01T01:02:03.0"]) nonexistent = pd.to_datetime(["2015-03-29 02:30:00", - "2015-03-29 03:30:00"]) + "2015-03-29 03:30:00"]).as_unit("ns") ambiguous = pd.to_datetime(["2018-10-28 01:20:00", "2018-10-28 02:36:00", "2018-10-28 03:46:00"])