itholic opened a new pull request, #49041: URL: https://github.com/apache/spark/pull/49041
### What changes were proposed in this pull request? This PR introduces a generalized and streamlined approach to handling exceptions in the Spark Connect Python client. This PR includes: 1. Replaces the large if-else block for exception type matching with a more extensible class mapping (`EXCEPTION_CLASS_MAPPING`). 2. Maintains compatibility for existing exception types while making it easier to add new ones in the future. 3. Keeps the unique handling logic for specific exceptions like `PythonException` intact. ### Why are the changes needed? The previous exception handling logic relied on a large `if-else` block, which was not scalable or maintainable as more exception types were added. Generalizing the exception handling mechanism reduces the complexity of the code, making it easier to extend when adding new exception types now requires minimal changes to the `EXCEPTION_CLASS_MAPPING`, avoiding duplication of logic. ### Does this PR introduce _any_ user-facing change? No API changes, but it enhances the internal implementation of exception handling. ### How was this patch tested? Added new UTs to verify that all existing exception handling scenarios are still supported. ### Was this patch authored or co-authored using generative AI tooling? No. -- 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]
