Skip to content

Commit 13001c8

Browse files
author
Tom McCormick
committed
simplify code, return to previous structure
1 parent 80176e8 commit 13001c8

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

pyiceberg/io/pyarrow.py

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

405405
if not uri.scheme:
406-
scheme = default_scheme
407-
if not uri.netloc:
408-
netloc = default_netloc
409-
410-
if scheme in ("hdfs", "viewfs"):
411-
return scheme, netloc, uri.path
406+
return default_scheme, default_netloc, os.path.abspath(location)
407+
elif uri.scheme in ("hdfs", "viewfs"):
408+
return uri.scheme, uri.netloc, uri.path
412409
else:
413-
# For non-HDFS URIs, include netloc in the path if present
414-
path = uri.path if uri.scheme else os.path.abspath(location)
415-
if netloc and not path.startswith(netloc):
416-
path = f"{netloc}{path}"
417-
return scheme, netloc, path
410+
return uri.scheme, uri.netloc, f"{uri.netloc}{uri.path}"
418411

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

tests/io/test_pyarrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2801,7 +2801,7 @@ def test_parse_location_defaults() -> None:
28012801
)
28022802
assert scheme == "scheme"
28032803
assert netloc == "netloc:8000"
2804-
assert path == "netloc:8000/foo/bar"
2804+
assert path == "/foo/bar"
28052805

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

0 commit comments

Comments
 (0)