Skip to content

Commit 37ff7ba

Browse files
author
Mrutunjay Kinagi
committed
fix(rest): support client.profile-name for sigv4 session
1 parent 067e0dc commit 37ff7ba

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

pyiceberg/catalog/rest/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@
5555
TableAlreadyExistsError,
5656
UnauthorizedError,
5757
)
58-
from pyiceberg.io import AWS_ACCESS_KEY_ID, AWS_REGION, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, FileIO, load_file_io
58+
from pyiceberg.io import (
59+
AWS_ACCESS_KEY_ID,
60+
AWS_PROFILE_NAME,
61+
AWS_REGION,
62+
AWS_SECRET_ACCESS_KEY,
63+
AWS_SESSION_TOKEN,
64+
FileIO,
65+
load_file_io,
66+
)
5967
from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec, assign_fresh_partition_spec_ids
6068
from pyiceberg.schema import Schema, assign_fresh_schema_ids
6169
from pyiceberg.table import (
@@ -704,6 +712,7 @@ def __init__(self, **properties: str):
704712
)
705713
)
706714
self._boto_session = boto3.Session(
715+
profile_name=get_first_property_value(self._properties, AWS_PROFILE_NAME),
707716
region_name=get_first_property_value(self._properties, AWS_REGION),
708717
botocore_session=self._properties.get(BOTOCORE_SESSION),
709718
aws_access_key_id=get_first_property_value(self._properties, AWS_ACCESS_KEY_ID),

tests/catalog/test_rest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,29 @@ def test_sigv4_adapter_override_retry_config(rest_mock: Mocker) -> None:
567567
assert adapter.max_retries.total == 3
568568

569569

570+
def test_sigv4_uses_client_profile_name(rest_mock: Mocker) -> None:
571+
with mock.patch("boto3.Session") as mock_session:
572+
RestCatalog(
573+
"rest",
574+
**{
575+
"uri": TEST_URI,
576+
"token": TEST_TOKEN,
577+
"rest.sigv4-enabled": "true",
578+
"rest.signing-region": "us-west-2",
579+
"client.profile-name": "rest-profile",
580+
},
581+
)
582+
583+
mock_session.assert_called_with(
584+
profile_name="rest-profile",
585+
region_name=None,
586+
botocore_session=None,
587+
aws_access_key_id=None,
588+
aws_secret_access_key=None,
589+
aws_session_token=None,
590+
)
591+
592+
570593
def test_list_tables_404(rest_mock: Mocker) -> None:
571594
namespace = "examples"
572595
rest_mock.get(

0 commit comments

Comments
 (0)