Skip to content

Commit

Permalink
[SPARK-43375][CONNECT] Improve the error messages for INVALID_CONNECT…
Browse files Browse the repository at this point in the history
…_URL

### What changes were proposed in this pull request?

This PR updates the error messages for the INVALID_CONNECT_URL error.

### Why are the changes needed?

To make the error messages more user-friendly.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Existing tests.

Closes #41044 from allisonwang-db/spark-43375-err-msg.

Authored-by: allisonwang-db <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
  • Loading branch information
allisonwang-db authored and zhengruifeng committed May 5, 2023
1 parent 7b5d7af commit e613563
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions python/pyspark/sql/connect/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def __init__(self, url: str, channelOptions: Optional[List[Tuple[str, Any]]] = N
raise PySparkValueError(
error_class="INVALID_CONNECT_URL",
message_parameters={
"detail": "URL scheme must be set to `sc`.",
"detail": "The URL must start with 'sc://'. Please update the URL to "
"follow the correct format, e.g., 'sc://hostname:port'.",
},
)
# Rewrite the URL to use http as the scheme so that we can leverage
Expand All @@ -185,8 +186,8 @@ def __init__(self, url: str, channelOptions: Optional[List[Tuple[str, Any]]] = N
raise PySparkValueError(
error_class="INVALID_CONNECT_URL",
message_parameters={
"detail": f"Path component for connection URI `{self.url.path}` "
f"must be empty.",
"detail": f"The path component '{self.url.path}' must be empty. Please update "
f"the URL to follow the correct format, e.g., 'sc://hostname:port'.",
},
)
self._extract_attributes()
Expand All @@ -210,7 +211,9 @@ def _extract_attributes(self) -> None:
raise PySparkValueError(
error_class="INVALID_CONNECT_URL",
message_parameters={
"detail": f"Parameter '{p}' is not a valid parameter key-value pair.",
"detail": f"Parameter '{p}' should be provided as a "
f"key-value pair separated by an equal sign (=). Please update "
f"the parameter to follow the correct format, e.g., 'key=value'.",
},
)
self.params[kv[0]] = urllib.parse.unquote(kv[1])
Expand All @@ -226,8 +229,9 @@ def _extract_attributes(self) -> None:
raise PySparkValueError(
error_class="INVALID_CONNECT_URL",
message_parameters={
"detail": f"Target destination {self.url.netloc} does not match "
f"'<host>:<port>' pattern.",
"detail": f"Target destination '{self.url.netloc}' should match the "
f"'<host>:<port>' pattern. Please update the destination to follow "
f"the correct format, e.g., 'hostname:port'.",
},
)

Expand Down

0 comments on commit e613563

Please sign in to comment.