kevinjqliu commented on code in PR #2291:
URL: https://github.com/apache/iceberg-python/pull/2291#discussion_r2302089466
##########
pyiceberg/io/pyarrow.py:
##########
@@ -387,15 +387,30 @@ def __init__(self, properties: Properties = EMPTY_DICT):
super().__init__(properties=properties)
@staticmethod
- def parse_location(location: str) -> Tuple[str, str, str]:
- """Return the path without the scheme."""
+ def parse_location(location: str, properties: Properties = EMPTY_DICT) ->
Tuple[str, str, str]:
+ """Return (scheme, netloc, path) for the given location.
+
+ Uses environment variables DEFAULT_SCHEME and DEFAULT_NETLOC
+ if scheme/netloc are missing.
+ """
uri = urlparse(location)
- if not uri.scheme:
- return "file", uri.netloc, os.path.abspath(location)
- elif uri.scheme in ("hdfs", "viewfs"):
- return uri.scheme, uri.netloc, uri.path
+
+ # Load defaults from environment
Review Comment:
nit: these are no longer env vars
##########
pyiceberg/io/pyarrow.py:
##########
@@ -387,15 +387,30 @@ def __init__(self, properties: Properties = EMPTY_DICT):
super().__init__(properties=properties)
@staticmethod
- def parse_location(location: str) -> Tuple[str, str, str]:
- """Return the path without the scheme."""
+ def parse_location(location: str, properties: Properties = EMPTY_DICT) ->
Tuple[str, str, str]:
+ """Return (scheme, netloc, path) for the given location.
+
+ Uses environment variables DEFAULT_SCHEME and DEFAULT_NETLOC
+ if scheme/netloc are missing.
+ """
uri = urlparse(location)
- if not uri.scheme:
- return "file", uri.netloc, os.path.abspath(location)
- elif uri.scheme in ("hdfs", "viewfs"):
- return uri.scheme, uri.netloc, uri.path
+
+ # Load defaults from environment
Review Comment:
maybe something like, "If scheme/netloc are missing, fallback to use
DEFAULT_SCHEME and DEFAULT_NETLOC properties"
##########
pyiceberg/io/pyarrow.py:
##########
@@ -387,15 +387,30 @@ def __init__(self, properties: Properties = EMPTY_DICT):
super().__init__(properties=properties)
@staticmethod
- def parse_location(location: str) -> Tuple[str, str, str]:
- """Return the path without the scheme."""
+ def parse_location(location: str, properties: Properties = EMPTY_DICT) ->
Tuple[str, str, str]:
+ """Return (scheme, netloc, path) for the given location.
+
+ Uses environment variables DEFAULT_SCHEME and DEFAULT_NETLOC
+ if scheme/netloc are missing.
+ """
uri = urlparse(location)
- if not uri.scheme:
- return "file", uri.netloc, os.path.abspath(location)
- elif uri.scheme in ("hdfs", "viewfs"):
- return uri.scheme, uri.netloc, uri.path
+
+ # Load defaults from environment
+ default_scheme = properties.get("DEFAULT_SCHEME", "file")
+ default_netloc = properties.get("DEFAULT_NETLOC", "")
+
+ # Apply logic
+ scheme = uri.scheme or default_scheme
+ netloc = uri.netloc or default_netloc
Review Comment:
wdyt about keeping this logic inside of an
```
if not uri.scheme:
scheme = properties.get("DEFAULT_SCHEME", "file")
netloc = uri.properties.get("DEFAULT_NETLOC", "")
```
block?
since this is only applicable in the case where path without scheme is
ambiguous.
the logic is never applied when the scheme is present
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]