Skip to content

[SPARK-58332][PYTHON][TEST] Move compare_or_generate_golden_matrix into GoldenFileTestMixin#57510

Open
Spenserrrr wants to merge 1 commit into
apache:masterfrom
Spenserrrr:centralize-golden-matrix-helper
Open

[SPARK-58332][PYTHON][TEST] Move compare_or_generate_golden_matrix into GoldenFileTestMixin#57510
Spenserrrr wants to merge 1 commit into
apache:masterfrom
Spenserrrr:centralize-golden-matrix-helper

Conversation

@Spenserrrr

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

compare_or_generate_golden_matrix was duplicated verbatim across three PyArrow golden-file test files:

  • python/pyspark/tests/upstream/pyarrow/test_pyarrow_array_cast.py
  • python/pyspark/tests/upstream/pyarrow/test_pyarrow_arrow_to_pandas_default.py
  • python/pyspark/tests/upstream/pyarrow/test_pyarrow_arrow_to_pandas_non_default.py

This PR moves it into GoldenFileTestMixin (python/pyspark/testing/goldenutils.py), which all three suites already inherit, and removes the local copies. Imports that became unused after the removal (inspect, os, typing.Callable/List/Optional) are dropped from the test files.

This is a follow-up to #57435, where reviewers asked to centralize the duplicated matrix driver into the mixin.

Why are the changes needed?

Removes duplicated test machinery so the golden-file matrix driver has a single implementation, making it easier to maintain and reuse for future golden-file suites.

Does this PR introduce any user-facing change?

No. Test-only, behavior-preserving refactor.

How was this patch tested?

Existing suites pass in compare mode (no golden files regenerated):

python -m pytest \
  python/pyspark/tests/upstream/pyarrow/test_pyarrow_array_cast.py \
  python/pyspark/tests/upstream/pyarrow/test_pyarrow_arrow_to_pandas_default.py \
  python/pyspark/tests/upstream/pyarrow/test_pyarrow_arrow_to_pandas_non_default.py

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

Generated-by: Claude Code (Opus 4.8)

…to GoldenFileTestMixin

### What changes were proposed in this pull request?
`compare_or_generate_golden_matrix` was duplicated verbatim across three PyArrow
golden-file test files. This moves it into `GoldenFileTestMixin`
(`python/pyspark/testing/goldenutils.py`), which all three suites already inherit,
and removes the local copies.

### Why are the changes needed?
Removes duplicated test machinery so the golden-file matrix driver has a single
implementation, following up on review feedback in apache#57435.

### Does this PR introduce _any_ user-facing change?
No. Test-only, behavior-preserving refactor.

### How was this patch tested?
Existing suites pass in compare mode (no golden files regenerated):
test_pyarrow_array_cast, test_pyarrow_arrow_to_pandas_default,
test_pyarrow_arrow_to_pandas_non_default.

### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)

Co-authored-by: Isaac
@Spenserrrr
Spenserrrr marked this pull request as ready for review July 24, 2026 20:10
@Spenserrrr

Copy link
Copy Markdown
Contributor Author

Hi @Yicong-Huang and @uros-b! This is the follow-up to #57435 that removes the duplicated compare_or_generate_golden_matrix. Please let me know if there is anything you want me to revise. Thanks!

@uros-b

uros-b commented Jul 24, 2026

Copy link
Copy Markdown
Member

Thank you @Spenserrrr! cc @Yicong-Huang

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