Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-51176][PYTHON][CONNECT] Meet consistency for unexpected errors PySpark Connect <> Classic #49926

Closed
wants to merge 3 commits into from
Closed
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
35 changes: 33 additions & 2 deletions python/pyspark/errors/exceptions/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
QueryContextType,
StreamingPythonRunnerInitializationException as BaseStreamingPythonRunnerInitException,
PickleException as BasePickleException,
UnknownException as BaseUnknownException,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -114,8 +115,8 @@ def convert_exception(
contexts=contexts,
)

# Return SparkConnectGrpcException if there is no matched exception class
return SparkConnectGrpcException(
# Return UnknownException if there is no matched exception class
return UnknownException(
message,
reason=info.reason,
messageParameters=message_parameters,
Expand Down Expand Up @@ -217,6 +218,36 @@ def __str__(self) -> str:
return self.getMessage()


class UnknownException(SparkConnectGrpcException, BaseUnknownException):
"""
Exception for unmapped errors in Spark Connect.
This class is functionally identical to SparkConnectGrpcException but has a different name
for consistency.
"""

def __init__(
self,
message: Optional[str] = None,
errorClass: Optional[str] = None,
messageParameters: Optional[Dict[str, str]] = None,
reason: Optional[str] = None,
sql_state: Optional[str] = None,
server_stacktrace: Optional[str] = None,
display_server_stacktrace: bool = False,
contexts: Optional[List[BaseQueryContext]] = None,
) -> None:
super().__init__(
message=message,
errorClass=errorClass,
messageParameters=messageParameters,
reason=reason,
sql_state=sql_state,
server_stacktrace=server_stacktrace,
display_server_stacktrace=display_server_stacktrace,
contexts=contexts,
)


class AnalysisException(SparkConnectGrpcException, BaseAnalysisException):
"""
Failed to analyze a SQL query plan, thrown from Spark Connect.
Expand Down