HyukjinKwon commented on code in PR #52755:
URL: https://github.com/apache/spark/pull/52755#discussion_r2471867686
##########
python/pyspark/errors/exceptions/captured.py:
##########
@@ -118,68 +118,45 @@ def getErrorClass(self) -> Optional[str]:
def getMessageParameters(self) -> Optional[Dict[str, str]]:
from pyspark import SparkContext
from py4j.java_gateway import is_instance_of
- from py4j.protocol import Py4JError
assert SparkContext._gateway is not None
gw = SparkContext._gateway
if self._origin is not None and is_instance_of(
gw, self._origin, "org.apache.spark.SparkThrowable"
):
- try:
- return dict(self._origin.getMessageParameters())
- except Py4JError as e:
- if "py4j.Py4JException" in str(e) and "Method
getMessageParameters" in str(e):
- return None
- raise e
+ return
dict(SparkContext._jvm.PythonErrorUtils.getMessageParameters(self._origin))
else:
return None
def getSqlState(self) -> Optional[str]:
from pyspark import SparkContext
from py4j.java_gateway import is_instance_of
- from py4j.protocol import Py4JError
assert SparkContext._gateway is not None
gw = SparkContext._gateway
if self._origin is not None and is_instance_of(
gw, self._origin, "org.apache.spark.SparkThrowable"
):
- try:
- return self._origin.getSqlState()
- except Py4JError as e:
- if "py4j.Py4JException" in str(e) and "Method getSqlState" in
str(e):
- return None
- raise e
+ return
dict(SparkContext._jvm.PythonErrorUtils.getSqlState(self._origin))
Review Comment:
Yeah, it's better to be a dict explicitly - the returned instance is a Py4J
instance that inherits `dict`.
--
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]