You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2023/01/29 07:18:28 UTC
[spark] branch master updated: [SPARK-42225][CONNECT] Add `SparkConnectIllegalArgumentException` to handle Spark Connect error precisely
This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 2842d8aa25e [SPARK-42225][CONNECT] Add `SparkConnectIllegalArgumentException` to handle Spark Connect error precisely
2842d8aa25e is described below
commit 2842d8aa25ee16918421850f70fa74bc815ae6e8
Author: itholic <ha...@databricks.com>
AuthorDate: Sun Jan 29 16:18:12 2023 +0900
[SPARK-42225][CONNECT] Add `SparkConnectIllegalArgumentException` to handle Spark Connect error precisely
### What changes were proposed in this pull request?
This PR proposes to add `SparkConnectIllegalArgumentException`.
### Why are the changes needed?
To handle Spark Connect error precisely by catching `IllegalArgumentException` before unexpectedly raise `SparkConnectGrpcException`.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Manually tested.
Closes #39783 from itholic/SPARK-42225.
Authored-by: itholic <ha...@databricks.com>
Signed-off-by: Hyukjin Kwon <gu...@apache.org>
---
python/docs/source/reference/pyspark.errors.rst | 1 +
python/pyspark/errors/__init__.py | 2 ++
python/pyspark/errors/exceptions.py | 6 ++++++
python/pyspark/sql/connect/client.py | 5 +++++
4 files changed, 14 insertions(+)
diff --git a/python/docs/source/reference/pyspark.errors.rst b/python/docs/source/reference/pyspark.errors.rst
index a5e1d78fa62..1d54c6babe0 100644
--- a/python/docs/source/reference/pyspark.errors.rst
+++ b/python/docs/source/reference/pyspark.errors.rst
@@ -42,6 +42,7 @@ Classes
SparkConnectGrpcException
SparkConnectParseException
SparkConnectTempTableAlreadyExistsException
+ SparkConnectIllegalArgumentException
Methods
diff --git a/python/pyspark/errors/__init__.py b/python/pyspark/errors/__init__.py
index e747ed30247..7faa0768a24 100644
--- a/python/pyspark/errors/__init__.py
+++ b/python/pyspark/errors/__init__.py
@@ -35,6 +35,7 @@ from pyspark.errors.exceptions import ( # noqa: F401
SparkConnectAnalysisException,
SparkConnectParseException,
SparkConnectTempTableAlreadyExistsException,
+ SparkConnectIllegalArgumentException,
)
@@ -55,4 +56,5 @@ __all__ = [
"SparkConnectAnalysisException",
"SparkConnectParseException",
"SparkConnectTempTableAlreadyExistsException",
+ "SparkConnectIllegalArgumentException",
]
diff --git a/python/pyspark/errors/exceptions.py b/python/pyspark/errors/exceptions.py
index 723cd9540d6..a799f4522de 100644
--- a/python/pyspark/errors/exceptions.py
+++ b/python/pyspark/errors/exceptions.py
@@ -371,3 +371,9 @@ class PySparkTypeError(PySparkException, TypeError):
"""
Wrapper class for TypeError to support error classes.
"""
+
+
+class SparkConnectIllegalArgumentException(SparkConnectGrpcException):
+ """
+ Passed an illegal or inappropriate argument from Spark Connect server.
+ """
diff --git a/python/pyspark/sql/connect/client.py b/python/pyspark/sql/connect/client.py
index 7409a2a8231..efc970d6a4c 100644
--- a/python/pyspark/sql/connect/client.py
+++ b/python/pyspark/sql/connect/client.py
@@ -42,6 +42,7 @@ from pyspark.errors import (
SparkConnectAnalysisException,
SparkConnectParseException,
SparkConnectTempTableAlreadyExistsException,
+ SparkConnectIllegalArgumentException,
)
from pyspark.sql.types import (
DataType,
@@ -626,6 +627,10 @@ class SparkConnectClient(object):
raise SparkConnectTempTableAlreadyExistsException(
info.metadata["message"], plan=info.metadata["plan"]
) from None
+ elif reason == "java.lang.IllegalArgumentException":
+ message = info.metadata["message"]
+ message = message if message != "" else status.message
+ raise SparkConnectIllegalArgumentException(message) from None
else:
raise SparkConnectGrpcException(
status.message, reason=info.reason
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org