[SPARK-43847][PYTHON] Throw structured error when reading Protobuf descriptor file fails#56174
Open
brijrajk wants to merge 1 commit into
Open
[SPARK-43847][PYTHON] Throw structured error when reading Protobuf descriptor file fails#56174brijrajk wants to merge 1 commit into
brijrajk wants to merge 1 commit into
Conversation
…scriptor file fails Raise `PySparkRuntimeError` with error class `PROTOBUF_DESCRIPTOR_FILE_NOT_FOUND` in `_read_descriptor_set_file()` instead of propagating a raw Python `OSError`, matching the structured error already defined on the Scala side. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
f64f232 to
be7a373
Compare
Contributor
Author
|
Could a committer please review this? It raises a structured |
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?
_read_descriptor_set_file()inpyspark.sql.protobuf.functionsnow raisesPySparkRuntimeErrorwith error classPROTOBUF_DESCRIPTOR_FILE_NOT_FOUNDinstead of propagating a raw Python
OSError/FileNotFoundErrorwhen thedescriptor file cannot be read.
The error class and its message already existed on the Scala side
(
common/utils/src/main/resources/error/error-conditions.json); this PR addsthe matching entry to
python/pyspark/errors/error-conditions.jsonand wiresit up in the Python code.
Why are the changes needed?
Before this fix, users who pass a wrong or missing descriptor file path get a
bare Python OS error with no Spark context:
After this fix they get a structured Spark error consistent with the rest of
the PySpark error framework:
Does this PR introduce any user-facing change?
Yes. Users who catch
OSError/FileNotFoundErroraroundfrom_protobuf/to_protobufcalls that supply adescFilePathwill now need to catchPySparkRuntimeErrorinstead (or the common basePySparkException). Theerror message is clearer and includes the file path.
How was this patch tested?
Added
python/pyspark/sql/tests/test_protobuf.pywithtest_read_descriptor_set_file_not_found, which asserts that a missing pathraises
PySparkRuntimeErrorwith the correct error class andfilePathmessage parameter.
Run locally with:
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Sonnet 4.6