diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py index d2432e80e7..f554f35369 100644 --- a/pyiceberg/io/pyarrow.py +++ b/pyiceberg/io/pyarrow.py @@ -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 @@ -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