[SPARK-57192][PYSPARK] Fix classic addArtifacts with multiple paths#56245
Closed
wbo4958 wants to merge 1 commit into
Closed
[SPARK-57192][PYSPARK] Fix classic addArtifacts with multiple paths#56245wbo4958 wants to merge 1 commit into
wbo4958 wants to merge 1 commit into
Conversation
Contributor
Author
|
Hi @HyukjinKwon, @zhengruifeng, @cloud-fan, Could you help review this PR? Thx |
HyukjinKwon
approved these changes
Jun 1, 2026
Member
|
Merged to master and branch-4.x. |
HyukjinKwon
pushed a commit
that referenced
this pull request
Jun 1, 2026
### What changes were proposed in this pull request?
This PR fixes classic PySpark `SparkSession.addArtifacts` to handle multiple paths in
one call.
The classic implementation previously forwarded all paths as positional arguments to
`SparkContext.addPyFile`, `SparkContext.addArchive`, or `SparkContext.addFile`. Those
APIs accept one path at a time, so this PR updates classic `addArtifacts` to call the
underlying SparkContext API once per path.
This PR also adds regression coverage for adding multiple Python files in a single
`addArtifacts(..., pyfile=True)` call.
### Why are the changes needed?
Classic PySpark currently fails for useful multi-path calls such as:
```python
spark.addArtifacts("a.py", "b.py", "c.py", pyfile=True)
```
with:
```
TypeError: SparkContext.addPyFile() takes 2 positional arguments but 4 were given
```
The public API accepts *path, so classic Spark should support multiple artifacts
consistently.
### Does this PR introduce any user-facing change?
Yes. Classic PySpark users can now add multiple artifacts in one
SparkSession.addArtifacts call when using `pyfile=True, archive=True, or file=True`.
### How was this patch tested?
Added a regression test for adding multiple Python files in one call.
Also manually ran:
```
env -u SPARK_CONF_DIR PYTHONPATH="python:python/lib/py4j-0.10.9.9-src.zip"
SPARK_HOME="$PWD" \
python3 -m unittest pyspark.sql.tests.test_artifact.ArtifactTests.test_add_multiple_pyfiles
```
and a standalone local Spark repro covering pyfile=True, file=True, and archive=True.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5.5)
Closes #56245 from wbo4958/fix-addartifacts.
Authored-by: Bobby Wang <wbo4958@gmail.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
(cherry picked from commit 2242318)
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR fixes classic PySpark
SparkSession.addArtifactsto handle multiple paths inone call.
The classic implementation previously forwarded all paths as positional arguments to
SparkContext.addPyFile,SparkContext.addArchive, orSparkContext.addFile. ThoseAPIs accept one path at a time, so this PR updates classic
addArtifactsto call theunderlying SparkContext API once per path.
This PR also adds regression coverage for adding multiple Python files in a single
addArtifacts(..., pyfile=True)call.Why are the changes needed?
Classic PySpark currently fails for useful multi-path calls such as:
with:
The public API accepts *path, so classic Spark should support multiple artifacts
consistently.
Does this PR introduce any user-facing change?
Yes. Classic PySpark users can now add multiple artifacts in one
SparkSession.addArtifacts call when using
pyfile=True, archive=True, or file=True.How was this patch tested?
Added a regression test for adding multiple Python files in one call.
Also manually ran:
and a standalone local Spark repro covering pyfile=True, file=True, and archive=True.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5.5)