Skip to content

[SPARK-54944][PYTHON][TEST] Add tests for pa.Array.to_pandas with default arguments#55031

Open
zhengruifeng wants to merge 11 commits intoapache:masterfrom
zhengruifeng:test_arrow_to_pandas_with_default
Open

[SPARK-54944][PYTHON][TEST] Add tests for pa.Array.to_pandas with default arguments#55031
zhengruifeng wants to merge 11 commits intoapache:masterfrom
zhengruifeng:test_arrow_to_pandas_with_default

Conversation

@zhengruifeng
Copy link
Contributor

What changes were proposed in this pull request?

Add test_pyarrow_arrow_to_pandas_default.py to monitor PyArrow's pa.Array.to_pandas() behavior with default arguments across all major Arrow types, using golden file comparison.

Why are the changes needed?

PySpark relies on specific to_pandas() conversion behaviors. This test captures the current behavior in a golden file so that any changes in future PyArrow upgrades are detected automatically.

Does this PR introduce any user-facing change?

No. Test-only change.

How was this patch tested?

  • New test PyArrowArrayToPandasDefaultTests covering 122 cases:
    • All scalar types (int8–int64, uint8–uint64, float32/64, bool, string, large_string, binary, large_binary, decimal128, date32/64, timestamp with all units and timezone, duration with all units, time32/time64, null)
    • Each with standard, nullable, and empty variants
    • Deeply nested types (list of list/struct/map, struct of struct/list/map, map of list/struct/map)
    • Dictionary type
  • Golden file golden_pyarrow_arrow_to_pandas_default.csv records expected results
  • Added repr_pandas_series_value to GoldenFileTestMixin for proper pd.Series formatting in repr_value
  • Registered in modules.py
  • All existing tests continue to pass

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

Yes.

… with default args

Add test_pyarrow_arrow_to_pandas_default.py to monitor PyArrow's
to_pandas() behavior across all major Arrow types with golden file
comparison, ensuring PySpark's assumptions remain valid across versions.

Co-authored-by: Isaac
Add list<list>, list<struct>, list<map>, struct<struct>, struct<list>,
struct<map>, map with list/struct/map values to cover deep nesting.

Co-authored-by: Isaac
Move compare_or_generate_golden_matrix back to test files instead of the
shared mixin. Add repr_pandas_series_value to GoldenFileTestMixin so
repr_value handles pd.Series, removing the need for a custom _repr_result.

Co-authored-by: Isaac
Co-authored-by: Isaac
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