Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/pyspark/errors/exceptions/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def convert_exception(
if "errorClass" in info.metadata:
error_class = info.metadata["errorClass"]

if "messageParameters" in info.metadata:
message_parameters = json.loads(info.metadata["messageParameters"])

stacktrace: Optional[str] = None
if resp is not None and resp.HasField("root_error_idx"):
message = resp.errors[resp.root_error_idx].message
Expand Down
11 changes: 11 additions & 0 deletions python/pyspark/sql/tests/connect/test_connect_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3486,6 +3486,17 @@ def test_can_create_multiple_sessions_to_different_remotes(self):
PySparkSession.builder.create()
self.assertIn("Create a new SparkSession is only supported with SparkConnect.", str(e))

def test_get_message_parameters_without_enriched_error(self):
with self.sql_conf({"spark.sql.connect.enrichError.enabled": False}):
exception = None
try:
self.spark.sql("""SELECT a""")
except AnalysisException as e:
exception = e

self.assertIsNotNone(exception)
self.assertEqual(exception.getMessageParameters(), {"objectName": "`a`"})


class SparkConnectSessionWithOptionsTest(unittest.TestCase):
def setUp(self) -> None:
Expand Down