Skip to content

[SPARK-56863][PYTHON][PS][TESTS] Drop redundant SQLTestUtils#55875

Open
zhengruifeng wants to merge 3 commits into
apache:masterfrom
zhengruifeng:drop-sqltestutils-reusedmixed
Open

[SPARK-56863][PYTHON][PS][TESTS] Drop redundant SQLTestUtils#55875
zhengruifeng wants to merge 3 commits into
apache:masterfrom
zhengruifeng:drop-sqltestutils-reusedmixed

Conversation

@zhengruifeng
Copy link
Copy Markdown
Contributor

@zhengruifeng zhengruifeng commented May 14, 2026

What changes were proposed in this pull request?

Drop the redundant SQLTestUtils mixin from Python test classes whose primary base already chains to SQLTestUtils. Two cleanups in this PR.

1. ReusedMixedTestCase (python/pyspark/testing/connectutils.py)

-class ReusedMixedTestCase(ReusedConnectTestCase, SQLTestUtils):
+class ReusedMixedTestCase(ReusedConnectTestCase):

Its parent ReusedConnectTestCase already mixes in SQLTestUtils:

class ReusedConnectTestCase(PySparkBaseTestCase, SQLTestUtils, PySparkErrorTestUtils):

The from pyspark.testing.sqlutils import SQLTestUtils import is kept because ReusedConnectTestCase (still in the same file) uses it.

2. 139 PandasOnSparkTestCase-based classes under python/pyspark/pandas/tests/

PandasOnSparkTestCase already chains to SQLTestUtils:

PandasOnSparkTestCase -> ReusedSQLTestCase -> SQLTestUtils

so explicitly mixing SQLTestUtils in again on top of PandasOnSparkTestCase (and an XxxMixin body trait) is dead weight. This PR drops the redundant SQLTestUtils mixin -- and the now-unused from pyspark.testing.sqlutils import SQLTestUtils import -- from 139 test classes following the pattern:

class FooTests(
    FooTestsMixin,
    PandasOnSparkTestCase,
    SQLTestUtils,   # <-- redundant
):
    pass

The MRO, inherited helper methods (sql_conf, table, temp_view, ...), and unittest.TestCase subclass relationship are all unchanged after the drop. Verified across a representative sample (ReusedMixedTestCase, NamespaceTests, NumPyCompatTests, UnionTests, SparkFrameMethodsTests):

class is TestCase inherits SQLTestUtils sql_conf resolves
ReusedMixedTestCase
NamespaceTests
NumPyCompatTests
UnionTests
SparkFrameMethodsTests

Classes elsewhere that legitimately use SQLTestUtils as their main TestCase-adjacent base (e.g. QueryExecutionListenerTests in python/pyspark/sql/tests/test_listener.py, which mixes unittest.TestCase and SQLTestUtils directly) are not touched.

Why are the changes needed?

Cleanup -- same spirit as the recently merged [SPARK-56841][SQL][TESTS] (Drop redundant BeforeAndAfterEach and SharedSparkSession mixins) but on the Python side.

Does this PR introduce any user-facing change?

No. Test-infra-only change.

How was this patch tested?

Existing tests. MRO / issubclass / inherited-method checks (above) confirm the behavior of affected classes is unchanged. py_compile over a sample of the edited files succeeds.

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

Generated-by: Claude opus-4-7

…usedMixedTestCase`

`ReusedMixedTestCase` was declared as

    class ReusedMixedTestCase(ReusedConnectTestCase, SQLTestUtils):

but its parent `ReusedConnectTestCase` already mixes in `SQLTestUtils`:

    class ReusedConnectTestCase(PySparkBaseTestCase, SQLTestUtils, PySparkErrorTestUtils):

so listing `SQLTestUtils` again on `ReusedMixedTestCase` is redundant. The MRO and the inherited helper methods (`sql_conf`, `table`, `temp_view`, ...) are unchanged after the drop:

    MRO before/after: ['ReusedMixedTestCase', 'ReusedConnectTestCase',
                       'PySparkBaseTestCase', 'TestCase', 'SQLTestUtils',
                       'PySparkErrorTestUtils', 'object']

The `from pyspark.testing.sqlutils import SQLTestUtils` import is kept because `ReusedConnectTestCase` still uses it.

Generated-by: Claude opus-4-7
@zhengruifeng zhengruifeng changed the title [PYTHON][CONNECT][TESTS] Drop redundant SQLTestUtils mixin from ReusedMixedTestCase [MINOR][PYTHON][CONNECT][TESTS] Drop redundant SQLTestUtils mixin from ReusedMixedTestCase May 14, 2026
…nSparkTestCase`-based test classes

`PandasOnSparkTestCase` already chains to `SQLTestUtils`:

    PandasOnSparkTestCase -> ReusedSQLTestCase -> SQLTestUtils

so explicitly mixing `SQLTestUtils` in again on top of `PandasOnSparkTestCase` (and an `XxxMixin` body trait) is dead weight. This commit drops the redundant `SQLTestUtils` mixin -- and the now-unused `from pyspark.testing.sqlutils import SQLTestUtils` import -- from 139 test classes under `python/pyspark/pandas/tests/` that follow the pattern:

    class FooTests(
        FooTestsMixin,
        PandasOnSparkTestCase,
        SQLTestUtils,   # <-- redundant
    ):
        pass

The MRO, inherited helper methods (`sql_conf`, `table`, `temp_view`, ...), and `unittest.TestCase` subclass relationship are all unchanged after the drop.

Classes elsewhere that legitimately use `SQLTestUtils` as their main TestCase-adjacent base (e.g. `QueryExecutionListenerTests` in `python/pyspark/sql/tests/test_listener.py`, which mixes `unittest.TestCase` and `SQLTestUtils` directly) are not touched.

Generated-by: Claude opus-4-7
@zhengruifeng zhengruifeng changed the title [MINOR][PYTHON][CONNECT][TESTS] Drop redundant SQLTestUtils mixin from ReusedMixedTestCase [PYTHON][PS][CONNECT][TESTS] Drop redundant SQLTestUtils mixin from ReusedMixedTestCase and 139 PandasOnSparkTestCase-based test classes May 14, 2026
@zhengruifeng zhengruifeng changed the title [PYTHON][PS][CONNECT][TESTS] Drop redundant SQLTestUtils mixin from ReusedMixedTestCase and 139 PandasOnSparkTestCase-based test classes [PYTHON][SPARK-56863][PS][CONNECT][TESTS] Drop redundant SQLTestUtils mixin from ReusedMixedTestCase and 139 PandasOnSparkTestCase-based test classes May 14, 2026
@zhengruifeng zhengruifeng changed the title [PYTHON][SPARK-56863][PS][CONNECT][TESTS] Drop redundant SQLTestUtils mixin from ReusedMixedTestCase and 139 PandasOnSparkTestCase-based test classes [PYTHON][SPARK-56863][PS][CONNECT][TESTS] Drop redundant SQLTestUtils May 14, 2026
…Utils` drop

Three test classes ended up with their bases split across three lines after dropping `SQLTestUtils`:

    class FooTests(
        FooTestsMixin, PandasOnSparkTestCase[, TestUtils]
    ):
        pass

`black` (CI's formatter) wants the bases on one line now that they fit under the 100-char limit:

    class FooTests(FooTestsMixin, PandasOnSparkTestCase[, TestUtils]):
        pass

Files:
- `python/pyspark/pandas/tests/diff_frames_ops/test_setitem_series.py`
- `python/pyspark/pandas/tests/test_frame_spark.py`
- `python/pyspark/pandas/tests/test_indexops_spark.py`

Generated-by: Claude opus-4-7
@zhengruifeng zhengruifeng changed the title [PYTHON][SPARK-56863][PS][CONNECT][TESTS] Drop redundant SQLTestUtils [SPARK-56863][PYTHON][PS][CONNECT][TESTS] Drop redundant SQLTestUtils May 14, 2026
@zhengruifeng zhengruifeng changed the title [SPARK-56863][PYTHON][PS][CONNECT][TESTS] Drop redundant SQLTestUtils [SPARK-56863][PYTHON][PS][TESTS] Drop redundant SQLTestUtils May 14, 2026
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