From 5a74e5a049aa52d19e802bea84b4b898d14f3a9b Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Mon, 8 Jan 2024 19:54:36 +0800 Subject: [PATCH] [SPARK-46621][PYTHON] Address null from Exception.getMessage in Py4J captured exception ### What changes were proposed in this pull request? This PR proposes to address null from `Exception.getMessage` in Py4J captured exception. It returns an empty string. ### Why are the changes needed? So whitelisted exceptions with an empty arguments are also covered. ### Does this PR introduce _any_ user-facing change? Virtually no. It only happens when whitelisted exceptions are created without any argument so `null` is located in `message`. ### How was this patch tested? Manually. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #44623 from HyukjinKwon/SPARK-46621. Authored-by: Hyukjin Kwon Signed-off-by: yangjie01 --- python/pyspark/errors/exceptions/captured.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/pyspark/errors/exceptions/captured.py b/python/pyspark/errors/exceptions/captured.py index 687bdec14154e..e78a7c7bce8a8 100644 --- a/python/pyspark/errors/exceptions/captured.py +++ b/python/pyspark/errors/exceptions/captured.py @@ -59,6 +59,8 @@ def __init__( ) self._desc = desc if desc is not None else cast(Py4JJavaError, origin).getMessage() + if self._desc is None: + self._desc = "" assert SparkContext._jvm is not None self._stackTrace = ( stackTrace