Skip to content

Commit a17eb89

Browse files
committed
Fix connect client doesn't support ipv6
1 parent adef6f3 commit a17eb89

File tree

1 file changed

+8
-11
lines changed
  • python/pyspark/sql/connect/client

1 file changed

+8
-11
lines changed

python/pyspark/sql/connect/client/core.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,22 +393,19 @@ def _extract_attributes(self) -> None:
393393
)
394394
self.set(kv[0], urllib.parse.unquote(kv[1]))
395395

396-
netloc = self.url.netloc.split(":")
397-
if len(netloc) == 1:
398-
self._host = netloc[0]
399-
self._port = DefaultChannelBuilder.default_port()
400-
elif len(netloc) == 2:
401-
self._host = netloc[0]
402-
self._port = int(netloc[1])
403-
else:
396+
if not self.url.hostname:
404397
raise PySparkValueError(
405398
errorClass="INVALID_CONNECT_URL",
406399
messageParameters={
407-
"detail": f"Target destination '{self.url.netloc}' should match the "
408-
f"'<host>:<port>' pattern. Please update the destination to follow "
409-
f"the correct format, e.g., 'hostname:port'.",
400+
"detail": f"Hostname is missing in the URL: '{self.url.geturl()}'. "
401+
"Please update the URL to follow the correct format, "
402+
"e.g., 'sc://hostname:port'.",
410403
},
411404
)
405+
self._host = self.url.hostname
406+
self._port = (
407+
self.url.port if self.url.port is not None else DefaultChannelBuilder.default_port()
408+
)
412409

413410
@property
414411
def secure(self) -> bool:

0 commit comments

Comments
 (0)