Skip to content

[SPARK-58602][PYTHON][TESTS][FOLLOWUP] Fix the test entry point of test_pyarrow_array_from_pandas_default - #57864

Closed
Spenserrrr wants to merge 1 commit into
apache:masterfrom
Spenserrrr:from-pandas-main-fix
Closed

[SPARK-58602][PYTHON][TESTS][FOLLOWUP] Fix the test entry point of test_pyarrow_array_from_pandas_default#57864
Spenserrrr wants to merge 1 commit into
apache:masterfrom
Spenserrrr:from-pandas-main-fix

Conversation

@Spenserrrr

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Change the __main__ entry point of test_pyarrow_array_from_pandas_default.py from main(globals()["__file__"]) to a bare main().

Why are the changes needed?

pyspark.testing.main(module=None) expects either no argument (it then resolves the real module name via __spec__) or a module name -- it forwards its argument straight to unittest.main(module=...). Passing globals()["__file__"] hands it a filesystem path, which unittest tries to import as a module name and fails:

ModuleNotFoundError: No module named '/__w/spark/spark/python/pyspark/tests/upstream/pyarrow/test_pyarrow_array_from_pandas_default'

This aborts the pyspark-sql test module on master (exit code 19) before the rest of the shard completes, so it is currently failing CI on master and on open PRs. Every other pyspark test file uses a bare main(); this was the only one passing a path.

Does this PR introduce any user-facing change?

No. Test-only fix.

How was this patch tested?

Ran the module both ways locally. Before, python -m pyspark.tests.upstream.pyarrow.test_pyarrow_array_from_pandas_default raised ModuleNotFoundError; after, it runs to completion (Ran 1 test ... OK). dev/lint-python --ruff is clean.

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

Generated-by: Claude Code (Opus 4.8)

…st_pyarrow_array_from_pandas_default

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

Change the `__main__` entry point of
`test_pyarrow_array_from_pandas_default.py` from `main(globals()["__file__"])`
to a bare `main()`.

### Why are the changes needed?

`pyspark.testing.main(module=None)` expects either no argument (it then resolves
the real module name via `__spec__`) or a module name -- it forwards its argument
straight to `unittest.main(module=...)`. Passing `globals()["__file__"]` hands it
a filesystem path, which `unittest` tries to import as a module name and fails:

```
ModuleNotFoundError: No module named '/__w/spark/spark/python/pyspark/tests/upstream/pyarrow/test_pyarrow_array_from_pandas_default'
```

This breaks the `pyspark-sql` test module on master (the run aborts with exit
code 19 before the rest of the shard completes). Every other pyspark test file
uses a bare `main()`; this was the only one passing a path.

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

No. Test-only fix.

### How was this patch tested?

Ran the module both ways locally. Before, `python -m pyspark.tests.upstream.pyarrow.test_pyarrow_array_from_pandas_default`
raised `ModuleNotFoundError`; after, it runs to completion (`Ran 1 test ... OK`).
`dev/lint-python --ruff` clean.

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

Generated-by: Claude Code (Opus 4.8)
@Spenserrrr
Spenserrrr marked this pull request as ready for review August 7, 2026 22:46
@Spenserrrr

Copy link
Copy Markdown
Contributor Author

Hi @zhengruifeng @Yicong-Huang! This is a one-line follow-up fixing a CI break on master: test_pyarrow_array_from_pandas_default.py calls main(globals()["file"]), which passes a file path to unittest.main(module=...) and fails the whole pyspark-sql shard with ModuleNotFoundError (exit code 19). Every other pyspark test uses a bare main(). This restores that. Could one of you take a look and merge when you have a moment, since it's currently red on master?

@Yicong-Huang Yicong-Huang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@uros-b

uros-b commented Aug 8, 2026

Copy link
Copy Markdown
Member

Thank you @Spenserrrr and @Yicong-Huang!

@uros-b uros-b closed this in e2f176e Aug 8, 2026
uros-b pushed a commit that referenced this pull request Aug 8, 2026
…t_pyarrow_array_from_pandas_default

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

Change the `__main__` entry point of `test_pyarrow_array_from_pandas_default.py` from `main(globals()["__file__"])` to a bare `main()`.

### Why are the changes needed?

`pyspark.testing.main(module=None)` expects either no argument (it then resolves the real module name via `__spec__`) or a module name -- it forwards its argument straight to `unittest.main(module=...)`. Passing `globals()["__file__"]` hands it a filesystem path, which `unittest` tries to import as a module name and fails:

```
ModuleNotFoundError: No module named '/__w/spark/spark/python/pyspark/tests/upstream/pyarrow/test_pyarrow_array_from_pandas_default'
```

This aborts the `pyspark-sql` test module on master (exit code 19) before the rest of the shard completes, so it is currently failing CI on master and on open PRs. Every other pyspark test file uses a bare `main()`; this was the only one passing a path.

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

No. Test-only fix.

### How was this patch tested?

Ran the module both ways locally. Before, `python -m pyspark.tests.upstream.pyarrow.test_pyarrow_array_from_pandas_default` raised `ModuleNotFoundError`; after, it runs to completion (`Ran 1 test ... OK`). `dev/lint-python --ruff` is clean.

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

Generated-by: Claude Code (Opus 4.8)

Closes #57864 from Spenserrrr/from-pandas-main-fix.

Authored-by: Spenser Sun <hsun112358@gmail.com>
Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com>
(cherry picked from commit e2f176e)
Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com>
@uros-b

uros-b commented Aug 8, 2026

Copy link
Copy Markdown
Member

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.

3 participants