Skip to content

Commit

Permalink
Shuffle code location for better maintainability
Browse files Browse the repository at this point in the history
  • Loading branch information
jiakai-li committed Dec 24, 2024
1 parent 8404e6b commit 53951f5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyiceberg/io/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ def _initialize_fs(self, scheme: str, netloc: Optional[str] = None) -> FileSyste
"region": get_first_property_value(self.properties, S3_REGION, AWS_REGION),
}

# Override the default s3.region if netloc(bucket) resolves to a different region
try:
client_kwargs["region"] = resolve_s3_region(netloc)
except (OSError, TypeError):
pass

if proxy_uri := self.properties.get(S3_PROXY_URI):
client_kwargs["proxy_options"] = proxy_uri

Expand All @@ -377,12 +383,6 @@ def _initialize_fs(self, scheme: str, netloc: Optional[str] = None) -> FileSyste
if force_virtual_addressing := self.properties.get(S3_FORCE_VIRTUAL_ADDRESSING):
client_kwargs["force_virtual_addressing"] = property_as_bool(self.properties, force_virtual_addressing, False)

# Override the default s3.region if netloc(bucket) resolves to a different region
try:
client_kwargs["region"] = resolve_s3_region(netloc)
except (OSError, TypeError):
pass

return S3FileSystem(**client_kwargs)
elif scheme in ("hdfs", "viewfs"):
from pyarrow.fs import HadoopFileSystem
Expand Down

0 comments on commit 53951f5

Please sign in to comment.