Skip to content

[SPARK-58058][PYTHON][TESTS] Split slow PySpark test suites into smaller modules#57155

Closed
HyukjinKwon wants to merge 1 commit into
apache:masterfrom
HyukjinKwon:hyukjin/split-slow-pyspark-tests
Closed

[SPARK-58058][PYTHON][TESTS] Split slow PySpark test suites into smaller modules#57155
HyukjinKwon wants to merge 1 commit into
apache:masterfrom
HyukjinKwon:hyukjin/split-slow-pyspark-tests

Conversation

@HyukjinKwon

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This PR splits several large/slow PySpark test suites into smaller modules so
they run as separate test targets and parallelize better, reducing wall-clock
time. No test logic is changed; test methods are only relocated, following the
existing convention already used in the repo (e.g. test_split_apply_*,
test_stat_*).

The following suites are split, each with a matching Spark Connect parity module:

  • pyspark.sql.tests.pandas.test_pandas_cogrouped_map: move the heavier,
    self-contained tests (test_with_window_function, test_with_local_data,
    test_arrow_batch_slicing, test_cogroup_apply_in_pandas_with_logging) into
    a new test_pandas_cogrouped_map_misc module.
  • pyspark.sql.tests.arrow.test_arrow_cogrouped_map: extract shared helpers
    into CogroupedMapInArrowTestsFuncMixin and move the heavier tests into a new
    test_arrow_cogrouped_map_misc module.
  • pyspark.pandas.tests.data_type_ops.test_num_ops: move
    IntegralExtensionOpsTestsMixin and FractionalExtensionOpsTestsMixin into
    their own modules.
  • pyspark.pandas.tests.groupby.test_stat: move test_median into a new
    test_stat_median module.
  • pyspark.pandas.tests.groupby.test_split_apply: move the mean case into a
    new test_split_apply_mean module.

New modules are registered in dev/sparktestsupport/modules.py.

Why are the changes needed?

These suites are slow in CI. Splitting them lets the test runner schedule the
pieces in parallel, lowering total wall-clock time without dropping coverage.

Does this PR introduce any user-facing change?

No. Test-only change.

How was this patch tested?

Existing tests, only relocated across modules. Verified that the total number
of test methods is unchanged for each split suite, that all new and modified
modules import and collect, and that flake8 passes.

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

Generated-by: Cursor

@HyukjinKwon HyukjinKwon marked this pull request as draft July 9, 2026 07:25
@HyukjinKwon HyukjinKwon changed the title [SPARK-58058][PYTHON][TESTS] Split slow PySpark test suites into smaller modules [DO-NOT-MERGE][SPARK-58058][PYTHON][TESTS] Split slow PySpark test suites into smaller modules Jul 9, 2026
@HyukjinKwon

Copy link
Copy Markdown
Member Author

CI timing results (run on this PR)

All split modules pass. The one red job (pyspark-sql, pyspark-core, ...) failed only on pyspark.tests.test_import_spark (Unexpected 3rd party package 'numpy' imported during 'import pyspark'), which is unrelated to this test-only change and not part of this diff.

Measured per-module durations (classic / Spark Connect):

Suite base new module(s)
arrow cogrouped map 22s misc 23s
pandas cogrouped map 41s misc 25s
num_ops 27s / 28s integral_ext 37s / 50s, fractional_ext 26s / 40s
groupby stat 27s / 36s stat_median 12s / 15s
split_apply 29s / 41s split_apply_mean 29s / 41s

Each split lowers the longest single-module wall-clock via parallelism. arrow and split_apply are well balanced; num_ops, groupby stat, and pandas cogrouped map are functional splits but not tightly balanced (documented here for transparency; can be rebalanced in a follow-up if desired).

…ler modules

### What changes were proposed in this pull request?

This PR splits several large/slow PySpark test suites into smaller modules so
they run as separate test targets and parallelize better, reducing wall-clock
time. No test logic is changed; test methods are only relocated. Each split
follows the existing convention already used in the repo (e.g.
`test_split_apply_*`, `test_stat_*`).

The following suites are split, each with a matching Spark Connect parity module:

- `pyspark.sql.tests.pandas.test_pandas_cogrouped_map`: move the heavier,
  self-contained tests (`test_with_window_function`, `test_with_local_data`,
  `test_arrow_batch_slicing`, `test_cogroup_apply_in_pandas_with_logging`) into
  a new `test_pandas_cogrouped_map_misc` module.
- `pyspark.sql.tests.arrow.test_arrow_cogrouped_map`: extract shared helpers
  into `CogroupedMapInArrowTestsFuncMixin` and move the heavier tests into a new
  `test_arrow_cogrouped_map_misc` module.
- `pyspark.pandas.tests.data_type_ops.test_num_ops`: move
  `IntegralExtensionOpsTestsMixin` and `FractionalExtensionOpsTestsMixin` into
  their own modules, and further split the heavier `astype` and comparison
  (`eq`/`ne`/`lt`/`le`/`gt`/`ge`) tests of each into dedicated
  `*_astype_cmp` modules so the pieces are more evenly balanced.
- `pyspark.pandas.tests.groupby.test_stat`: move `test_median` into a new
  `test_stat_median` module.
- `pyspark.pandas.tests.groupby.test_split_apply`: move the `mean` case into a
  new `test_split_apply_mean` module.

New modules are registered in `dev/sparktestsupport/modules.py`.

### Why are the changes needed?

These suites are slow in CI. Splitting them lets the test runner schedule the
pieces in parallel, lowering total wall-clock time without dropping coverage.

### Does this PR introduce _any_ user-facing change?

No. Test-only change.

### How was this patch tested?

Existing tests, only relocated across modules. Verified that the total number
of test methods is unchanged for each split suite, that all new and modified
modules import and collect, and that `flake8` passes.

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

Generated-by: Cursor
@HyukjinKwon HyukjinKwon force-pushed the hyukjin/split-slow-pyspark-tests branch from 8e43895 to 72c8d83 Compare July 9, 2026 11:10
@HyukjinKwon HyukjinKwon marked this pull request as ready for review July 9, 2026 12:59
@HyukjinKwon HyukjinKwon changed the title [DO-NOT-MERGE][SPARK-58058][PYTHON][TESTS] Split slow PySpark test suites into smaller modules [SPARK-58058][PYTHON][TESTS] Split slow PySpark test suites into smaller modules Jul 9, 2026
@dongjoon-hyun

Copy link
Copy Markdown
Member

I also agree that pyspark.tests.test_import_spark failure is irrelevant.

HyukjinKwon added a commit that referenced this pull request Jul 9, 2026
…er modules

### What changes were proposed in this pull request?

This PR splits several large/slow PySpark test suites into smaller modules so
they run as separate test targets and parallelize better, reducing wall-clock
time. No test logic is changed; test methods are only relocated, following the
existing convention already used in the repo (e.g. `test_split_apply_*`,
`test_stat_*`).

The following suites are split, each with a matching Spark Connect parity module:

- `pyspark.sql.tests.pandas.test_pandas_cogrouped_map`: move the heavier,
  self-contained tests (`test_with_window_function`, `test_with_local_data`,
  `test_arrow_batch_slicing`, `test_cogroup_apply_in_pandas_with_logging`) into
  a new `test_pandas_cogrouped_map_misc` module.
- `pyspark.sql.tests.arrow.test_arrow_cogrouped_map`: extract shared helpers
  into `CogroupedMapInArrowTestsFuncMixin` and move the heavier tests into a new
  `test_arrow_cogrouped_map_misc` module.
- `pyspark.pandas.tests.data_type_ops.test_num_ops`: move
  `IntegralExtensionOpsTestsMixin` and `FractionalExtensionOpsTestsMixin` into
  their own modules.
- `pyspark.pandas.tests.groupby.test_stat`: move `test_median` into a new
  `test_stat_median` module.
- `pyspark.pandas.tests.groupby.test_split_apply`: move the `mean` case into a
  new `test_split_apply_mean` module.

New modules are registered in `dev/sparktestsupport/modules.py`.

### Why are the changes needed?

These suites are slow in CI. Splitting them lets the test runner schedule the
pieces in parallel, lowering total wall-clock time without dropping coverage.

### Does this PR introduce _any_ user-facing change?

No. Test-only change.

### How was this patch tested?

Existing tests, only relocated across modules. Verified that the total number
of test methods is unchanged for each split suite, that all new and modified
modules import and collect, and that `flake8` passes.

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

Generated-by: Cursor

Closes #57155 from HyukjinKwon/hyukjin/split-slow-pyspark-tests.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit 79f6dfa)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
@HyukjinKwon

Copy link
Copy Markdown
Member Author

Merge Summary:

Posted by merge_spark_pr.py

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