Skip to content

Commit 831170d

Browse files
authored
Fix setting force_virtual_addressing (#1923)
<!-- Thanks for opening a pull request! --> <!-- In the case this PR will resolve an issue, please replace ${GITHUB_ISSUE_ID} below with the actual Github issue id. --> <!-- Closes #${GITHUB_ISSUE_ID} --> # Rationale for this change This fix addressed issue #1922 and changed the behavior for both `_oss_fs` and `_s3_fs` to be able to parse `s3.force-virtual-addressing` correctly. # Are these changes tested? No unit tests are given to this change yet # Are there any user-facing changes? No <!-- In the case of user-facing changes, please add the changelog label. -->
1 parent 00c548a commit 831170d

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

mkdocs/docs/configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ PyIceberg uses [S3FileSystem](https://arrow.apache.org/docs/python/generated/pya
189189
| s3.access-key-id | admin | Configure the static access key id used to access the FileIO. |
190190
| s3.secret-access-key | password | Configure the static secret access key used to access the FileIO. |
191191
| s3.session-token | AQoDYXdzEJr... | Configure the static session token used to access the FileIO. |
192-
| s3.force-virtual-addressing | True | Whether to use virtual addressing of buckets. This must be set to True as OSS can only be accessed with virtual hosted style address. |
192+
| s3.force-virtual-addressing | True | Whether to use virtual addressing of buckets. This is set to `True` by default as OSS can only be accessed with virtual hosted style address. |
193193

194194
<!-- markdown-link-check-enable-->
195195

pyiceberg/io/pyarrow.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ def _initialize_oss_fs(self) -> FileSystem:
409409
"secret_key": get_first_property_value(self.properties, S3_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY),
410410
"session_token": get_first_property_value(self.properties, S3_SESSION_TOKEN, AWS_SESSION_TOKEN),
411411
"region": get_first_property_value(self.properties, S3_REGION, AWS_REGION),
412+
"force_virtual_addressing": property_as_bool(self.properties, S3_FORCE_VIRTUAL_ADDRESSING, True),
412413
}
413414

414415
if proxy_uri := self.properties.get(S3_PROXY_URI):
@@ -426,9 +427,6 @@ def _initialize_oss_fs(self) -> FileSystem:
426427
if session_name := get_first_property_value(self.properties, S3_ROLE_SESSION_NAME, AWS_ROLE_SESSION_NAME):
427428
client_kwargs["session_name"] = session_name
428429

429-
if force_virtual_addressing := self.properties.get(S3_FORCE_VIRTUAL_ADDRESSING):
430-
client_kwargs["force_virtual_addressing"] = property_as_bool(self.properties, force_virtual_addressing, False)
431-
432430
return S3FileSystem(**client_kwargs)
433431

434432
def _initialize_s3_fs(self, netloc: Optional[str]) -> FileSystem:
@@ -472,8 +470,8 @@ def _initialize_s3_fs(self, netloc: Optional[str]) -> FileSystem:
472470
if session_name := get_first_property_value(self.properties, S3_ROLE_SESSION_NAME, AWS_ROLE_SESSION_NAME):
473471
client_kwargs["session_name"] = session_name
474472

475-
if force_virtual_addressing := self.properties.get(S3_FORCE_VIRTUAL_ADDRESSING):
476-
client_kwargs["force_virtual_addressing"] = property_as_bool(self.properties, force_virtual_addressing, False)
473+
if self.properties.get(S3_FORCE_VIRTUAL_ADDRESSING) is not None:
474+
client_kwargs["force_virtual_addressing"] = property_as_bool(self.properties, S3_FORCE_VIRTUAL_ADDRESSING, False)
477475

478476
return S3FileSystem(**client_kwargs)
479477

0 commit comments

Comments
 (0)