Skip to content

[SPARK-59271][PYTHON][TESTS] Add tests for pandas.api.types is_* predicates - #58537

Open
Spenserrrr wants to merge 1 commit into
apache:masterfrom
Spenserrrr:pandas-api-types-tests
Open

[SPARK-59271][PYTHON][TESTS] Add tests for pandas.api.types is_* predicates#58537
Spenserrrr wants to merge 1 commit into
apache:masterfrom
Spenserrrr:pandas-api-types-tests

Conversation

@Spenserrrr

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add golden-file tests for the pandas type-introspection predicates (pandas.api.types.is_*) that PySpark depends on, in a new python/pyspark/tests/upstream/pandas package. Two classes split by input axis, matching how pandas itself implements them: the dtype predicates take a dtype or an array, the object predicates take an arbitrary object.

Why are the changes needed?

PySpark branches on the boolean these predicates return, so an upstream change misroutes control flow instead of corrupting one value. For example _create_from_pandas_with_arrow maps a pandas column to TimestampType only when is_datetime64_dtype says so, and that predicate answers False for a tz-aware or arrow-backed timestamp dtype. Nothing currently pins those answers.

Does this PR introduce any user-facing change?

No. Tests only.

How was this patch tested?

New tests, run across PyArrow 18-25 x pandas 2/3 (16/16 pass); the four cells that move on pandas 3 are recorded as version-guarded overrides.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5)

…icates

Add golden-file tests pinning the pandas type-introspection predicates
(pandas.api.types.is_*) that PySpark branches on, in a new
python/pyspark/tests/upstream/pandas package.

Two classes split by input axis: the dtype predicates take a dtype or an
array, the object predicates take an arbitrary object. The tests need no
Spark session.
@Spenserrrr
Spenserrrr marked this pull request as ready for review September 5, 2026 01:01
@Spenserrrr

Copy link
Copy Markdown
Contributor Author

Hi @zhengruifeng @Yicong-Huang! This PR adds golden files for pandas.api.types.is_*. Could you take a look when you have time? Thanks!

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.

1 participant