Skip to content

Commit beab612

Browse files
author
Tom McCormick
committed
simplify code, return to previous structure
1 parent cbff690 commit beab612

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

pyiceberg/io/pyarrow.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -398,18 +398,11 @@ def parse_location(location: str, properties: Properties = EMPTY_DICT) -> Tuple[
398398
default_netloc = properties.get("DEFAULT_NETLOC", "")
399399

400400
if not uri.scheme:
401-
scheme = default_scheme
402-
if not uri.netloc:
403-
netloc = default_netloc
404-
405-
if scheme in ("hdfs", "viewfs"):
406-
return scheme, netloc, uri.path
401+
return default_scheme, default_netloc, os.path.abspath(location)
402+
elif uri.scheme in ("hdfs", "viewfs"):
403+
return uri.scheme, uri.netloc, uri.path
407404
else:
408-
# For non-HDFS URIs, include netloc in the path if present
409-
path = uri.path if uri.scheme else os.path.abspath(location)
410-
if netloc and not path.startswith(netloc):
411-
path = f"{netloc}{path}"
412-
return scheme, netloc, path
405+
return uri.scheme, uri.netloc, f"{uri.netloc}{uri.path}"
413406

414407
def _initialize_fs(self, scheme: str, netloc: Optional[str] = None) -> FileSystem:
415408
"""Initialize FileSystem for different scheme."""

tests/io/test_pyarrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,7 @@ def test_parse_location_defaults() -> None:
26562656
)
26572657
assert scheme == "scheme"
26582658
assert netloc == "netloc:8000"
2659-
assert path == "netloc:8000/foo/bar"
2659+
assert path == "/foo/bar"
26602660

26612661
scheme, netloc, path = PyArrowFileIO.parse_location(
26622662
"/foo/bar", properties={"DEFAULT_SCHEME": "hdfs", "DEFAULT_NETLOC": "netloc:8000"}

0 commit comments

Comments
 (0)