[SPARK-55502][PYTHON] Unify UDF and UDTF Arrow conversion error handling#54398
Closed
Yicong-Huang wants to merge 3 commits intoapache:masterfrom
Closed
[SPARK-55502][PYTHON] Unify UDF and UDTF Arrow conversion error handling#54398Yicong-Huang wants to merge 3 commits intoapache:masterfrom
Yicong-Huang wants to merge 3 commits intoapache:masterfrom
Conversation
4b2718e to
e250ebf
Compare
Contributor
allisonwang-db
left a comment
There was a problem hiding this comment.
Can we add before and after error messages PR descriptions?
Contributor
Author
Thanks for the suggestion. I've added them in the PR description. |
aee750c to
0937f16
Compare
Rename the `is_udtf` parameter to `is_legacy` to better reflect its purpose: it controls the legacy UDTF pandas conversion path with broader Arrow exception handling, not whether the caller is a UDTF.
ceb1e2e to
31ae3fa
Compare
- Legacy path: keeps original "Exception thrown when converting
pandas.Series..." format with PySparkTypeError/PySparkValueError
(replaces UDTF_ARROW_TYPE_CAST_ERROR)
- Non-legacy path: new user-friendly "Cannot convert column '{name}'
from {dtype} to {arrow_type}." format
- Remove UDTF_ARROW_TYPE_CAST_ERROR from error-conditions.json
31ae3fa to
0215fb8
Compare
Contributor
Author
|
@allisonwang-db could you please have another look at this PR? thanks. also cc @zhengruifeng |
zhengruifeng
approved these changes
Mar 10, 2026
Contributor
|
merged to master |
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?
Remove the
is_udtfparameter fromPandasToArrowConversion.convert()and add a newis_legacyparameter to unify error handling for both UDF and UDTF Arrow conversions.Key changes:
is_udtfparameter and addedis_legacyfor clarity — it controls exception catch breadth and error message style, not UDTF-specific behaviorUDTF_ARROW_TYPE_CAST_ERRORand replaced with unifiedPySparkTypeError/PySparkValueErrorArrowExceptioncatch): keeps original"Exception thrown when converting pandas.Series..."error formatArrowInvalidcatch): uses new user-friendly error messages, with separate messages for TypeError and ValueErrorWhy are the changes needed?
The UDTF-specific
UDTF_ARROW_TYPE_CAST_ERRORerror condition was unnecessary — the same conversion errors occur in both UDF and UDTF contexts. Unifying error handling provides:Does this PR introduce any user-facing change?
Yes, error messages change for the non-legacy path (UDF/UDTF with
spark.sql.legacy.execution.pythonUDTF.pandas.conversion.enabled=false):TypeError (e.g. int → struct type mismatch):
Before:
After:
ValueError (e.g. string → double value error):
Before:
After:
Legacy UDTF path error messages remain unchanged.
How was this patch tested?
Updated existing unit tests.
Was this patch authored or co-authored using generative AI tooling?
No.