brijrajk opened a new pull request, #56174: URL: https://github.com/apache/spark/pull/56174
### What changes were proposed in this pull request? `_read_descriptor_set_file()` in `pyspark.sql.protobuf.functions` now raises `PySparkRuntimeError` with error class `PROTOBUF_DESCRIPTOR_FILE_NOT_FOUND` instead of propagating a raw Python `OSError` / `FileNotFoundError` when the descriptor 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 adds the matching entry to `python/pyspark/errors/error-conditions.json` and wires it 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: ``` FileNotFoundError: [Errno 2] No such file or directory: '/path/to/file.desc' ``` After this fix they get a structured Spark error consistent with the rest of the PySpark error framework: ``` PySparkRuntimeError: [PROTOBUF_DESCRIPTOR_FILE_NOT_FOUND] Error reading Protobuf descriptor file at path: /path/to/file.desc. ``` ### Does this PR introduce _any_ user-facing change? Yes. Users who catch `OSError` / `FileNotFoundError` around `from_protobuf` / `to_protobuf` calls that supply a `descFilePath` will now need to catch `PySparkRuntimeError` instead (or the common base `PySparkException`). The error message is clearer and includes the file path. ### How was this patch tested? Added `python/pyspark/sql/tests/test_protobuf.py` with `test_read_descriptor_set_file_not_found`, which asserts that a missing path raises `PySparkRuntimeError` with the correct error class and `filePath` message parameter. Run locally with: ``` PYTHONPATH=python python3 -m unittest pyspark.sql.tests.test_protobuf -v ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Sonnet 4.6 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
