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-50960][PYTHON][CONNECT] Add InvalidPlanInput to Spark Connect Python client #49616

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions python/pyspark/errors/exceptions/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ class SparkNoSuchElementException(SparkConnectGrpcException, BaseNoSuchElementEx
"""


class InvalidPlanInput(SparkConnectGrpcException):
"""
Error thrown when a connect plan is not valid.
"""


# Update EXCEPTION_CLASS_MAPPING here when adding a new exception
EXCEPTION_CLASS_MAPPING = {
"org.apache.spark.sql.catalyst.parser.ParseException": ParseException,
Expand All @@ -312,6 +318,7 @@ class SparkNoSuchElementException(SparkConnectGrpcException, BaseNoSuchElementEx
"org.apache.spark.api.python.PythonException": PythonException,
"org.apache.spark.SparkNoSuchElementException": SparkNoSuchElementException,
"org.apache.spark.SparkException": SparkException,
"org.apache.spark.sql.connect.common.InvalidPlanInput": InvalidPlanInput,
}


Expand Down
8 changes: 6 additions & 2 deletions python/pyspark/sql/tests/connect/test_parity_udtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

sql.udtf.UserDefinedTableFunction = UserDefinedTableFunction
from pyspark.sql.connect.functions import lit, udtf
from pyspark.errors.exceptions.connect import SparkConnectGrpcException, PythonException
from pyspark.errors.exceptions.connect import (
SparkConnectGrpcException,
PythonException,
InvalidPlanInput,
)


class UDTFParityTests(BaseUDTFTestsMixin, ReusedConnectTestCase):
Expand Down Expand Up @@ -54,7 +58,7 @@ def eval(self, a: int):
yield a + 1,

with self.assertRaisesRegex(
SparkConnectGrpcException, "Invalid Python user-defined table function return type."
InvalidPlanInput, "Invalid Python user-defined table function return type."
):
TestUDTF(lit(1)).collect()

Expand Down
Loading