Repository navigation
Conversation
|
Thank you. Please file a JIRA ID and use it like the other PRs before converting this PR back from |
89d8250 to
c163076
Compare
Since Spark 4.2.0 regular Python UDFs are Arrow-optimized by default (SPARK-54555), so the PySpark image can't run a plain `@udf` without PyArrow. Install it in the Python binding Dockerfile. Generated-by: Claude Code (Claude Opus 5.5)
c163076 to
320460a
Compare
pyarrow in PySpark K8s Dockerfilepyarrow in PySpark Docker image
|
Hi @dongjoon-hyun Sorry for the delay, it is updated now. Can you take a look? |
|
So wait @lisancao is this failing all Python UDFs in the container is it just producing an error message and then gracefully falling back? I thought we did auto graceful fallbacks but I could be getting things mixed up. |
Investigated a bit further. The fallback works fine on classic, but on Connect it fails on the server: the PyArrow check passes on the client (pyspark-client ships PyArrow), but PyArrow isn't installed in this image, so if you use it for your Connect server, the Python worker raises error: No module named 'pyarrow'. The supplement to this, if we don't want to update the docker image (or both) is we could explore a serverside fallback or just make a clearer error for the user advising them to set spark.sql.execution.pythonUDF.arrow.enabled to false if it doesn't have the install |
|
Ah that's a bad one. I think we should fix and install PyArrow in the docker container, but we should also improve the fallback for connect users who have pyarrow on the client but not on the server; if you're open to filing a JIRA for that too (doesn't need to block this PR). |
|
Thanks @holdenk, filed SPARK-60241 for the Connect fallback! |
|
@holdenk . This is not a regression because we never install it on the Apache Spark docker images, isn't it? |
|
So it's a regression because we enabled Arrow by default now and it doesn't fail back gracefully with Spark Connect. |
|
I mean it's not a regression of Apache Spark 4.2.1. |
|
Also, cc @dbtsai , @HyukjinKwon , @asl3 too from the original Apache Spark 4.2.0 PR because we were there together. |
|
True it's a regression from 4.1 but not 4.2 |
|
BTW, @holdenk , how does
We didn't have all packages even for PySpark SQL, do we? Given that, when it comes to the Apache Spark Docker images, the required package installation has been always the user's role, hasn't it?
|
|
It should fall back properly. Seems like minimal dep build passes (https://github.com/apache/spark/actions/workflows/build_python_minimum.yml) |
@HyukjinKwon if the minimum build shas PyArrow, and CI runs the Connect client and server on the same Python, such issue may not be detected, since server and client match in that case. My experience was that it only failed when the client has PyArrow and the server's Python doesn't, more nuanced than the original issue described. |
I agree fallback is higher priority, patching the image itself only solves the problem from a superficial place compared to root cause. I will defer to PMC on best course of action |
|
Thank you, @lisancao . |
| RUN apt-get update && \ | ||
| apt install -y --no-install-recommends python3 python3-pip && \ | ||
| # PyArrow is required by Arrow-optimized Python UDFs, the default since Spark 4.2 (SPARK-54555) | ||
| pip3 install --break-system-packages --no-cache-dir "pyarrow>=18.0.0" && \ |
There was a problem hiding this comment.
One side note: this doesn't sound like an appropriate approach for installing 3rd-party Python dependencies; --break-system-packages clearly signals the risk. Maybe we shouldn't use the OS Python and instead use another one (e.g., conda, uv, or something else) with the packages required by PySpark?
spark-test
left a comment
There was a problem hiding this comment.
Review summary
No PR-caused correctness defect was established. The retained advisory question concerns the ownership boundary for installing third-party packages into OS Python. The pandas concern does not invalidate the default remote worker improvement: client-side fallback is unchanged, while the non-legacy worker conversion uses PyArrow directly.
Findings
0 total: 0 P0, 0 P1, 0 P2, 0 P3.
No findings.
Existing discussions
- Unresolved decision challenge: Confirm the OS Python dependency installation policy — existing discussion
Verification
- Reviewed the complete Dockerfile patch, merge-base Dockerfile, and classic/Connect client and worker dependency paths. No image build or Spark tests were run.
PR description suggestions
- Narrow the user-facing claim to workers serving a separately provisioned Connect client, and clarify that regular UDF creation still checks pandas on the client. The statement that only pandas UDFs need pandas is broader than the current client implementation supports.
|
The AI review requested by @HyukjinKwon finished. Generated by Omnigent on Databricks |
|
I think we can close this for now, we're in agreement the fallback logic is more important. @lisancao do you want to take on the fallback fix? |
Yes, happy to. Thanks! |


What changes were proposed in this pull request?
This PR installs
pyarrow>=18.0.0(PySpark's minimum) in the PySpark Docker image.Why are the changes needed?
Since 4.2.0, regular Python UDFs are Arrow-optimized by default (SPARK-54555), so a plain
@udffails on the PySpark image withModuleNotFoundError: No module named 'pyarrow'. Theapache/sparkimages built from it (e.g.apache/spark:4.2.0-scala2.13-java21-python3-ubuntu) have the same problem. I left pandas out since only pandas UDFs need it.Does this PR introduce any user-facing change?
Yes. Default Python UDFs work on the PySpark image. The image grows by about 160 MB.
How was this patch tested?
Built the images from this branch over the 4.3.0-rc1 distribution and ran a default
@udfthrough Spark Connect: it fails before this change and passes after.This contribution is my original work, and I license it to the project under the project's open source license.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)