Skip to content

Conversation

@HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Dec 26, 2025

Rationale for this change

The test test_sequence_timestamp_from_int_with_unit() was marked with
@pytest.mark.pandas, meaning it was skipped when pandas was not installed.
This left the non-pandas code path untested.

Specifically in order to test:

if _pandas_api.have_pandas:
return _pandas_api.pd.Timestamp(value, tz=tzinfo, unit='ns')
# otherwise safely truncate to microsecond resolution datetime
if value % 1000 != 0:
raise ValueError(
f"Nanosecond resolution temporal type {value} is not safely "
"convertible to microseconds to convert to datetime.datetime. "
"Install pandas to return as Timestamp with nanosecond "
"support or access the .value attribute."
)

The TODO was introduced in commit 286bf7c when making pandas
an optional dependency:

# TODO(wesm): This test might be rewritten to assert the actual behavior
# when pandas is not installed

What changes are included in this PR?

Rewrote the test to work both with and without pandas by:

  1. Removed @pytest.mark.pandas decorator
  2. Removed TODO comment left and added conditional testing for nanosecond timestamp behavior:
    • With pandas: Validates pd.Timestamp with full nanosecond precision
    • Without pandas: Validates that as_py() raises ValueError for values
      not safely convertible to microseconds

Are these changes tested?

Yes. I manually tested with/without pandas:

conda remove pandas
pytest pyarrow/tests/test_convert_builtin.py -k "timestamp_from_int_with_unit" -xvs
conda install pandas==2.3.3
pytest pyarrow/tests/test_convert_builtin.py -k "timestamp_from_int_with_unit" -xvs

Are there any user-facing changes?

No, test-only.

@github-actions
Copy link

⚠️ GitHub issue #48654 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant