|
32 | 32 |
|
33 | 33 | from pyiceberg import __version__ |
34 | 34 | from pyiceberg.catalog import ( |
| 35 | + BOTOCORE_SESSION, |
35 | 36 | TOKEN, |
36 | 37 | URI, |
37 | 38 | WAREHOUSE_LOCATION, |
|
53 | 54 | TableAlreadyExistsError, |
54 | 55 | UnauthorizedError, |
55 | 56 | ) |
| 57 | +from pyiceberg.io import AWS_ACCESS_KEY_ID, AWS_REGION, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN |
56 | 58 | from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec, assign_fresh_partition_spec_ids |
57 | 59 | from pyiceberg.schema import Schema, assign_fresh_schema_ids |
58 | 60 | from pyiceberg.table import ( |
|
72 | 74 | from pyiceberg.typedef import EMPTY_DICT, UTF8, IcebergBaseModel, Identifier, Properties |
73 | 75 | from pyiceberg.types import transform_dict_value_to_str |
74 | 76 | from pyiceberg.utils.deprecated import deprecation_message |
75 | | -from pyiceberg.utils.properties import get_header_properties, property_as_bool |
| 77 | +from pyiceberg.utils.properties import get_first_property_value, get_header_properties, property_as_bool |
76 | 78 |
|
77 | 79 | if TYPE_CHECKING: |
78 | 80 | import pyarrow as pa |
@@ -390,11 +392,17 @@ class SigV4Adapter(HTTPAdapter): |
390 | 392 | def __init__(self, **properties: str): |
391 | 393 | super().__init__() |
392 | 394 | self._properties = properties |
| 395 | + self._boto_session = boto3.Session( |
| 396 | + region_name=get_first_property_value(self._properties, AWS_REGION), |
| 397 | + botocore_session=self._properties.get(BOTOCORE_SESSION), |
| 398 | + aws_access_key_id=get_first_property_value(self._properties, AWS_ACCESS_KEY_ID), |
| 399 | + aws_secret_access_key=get_first_property_value(self._properties, AWS_SECRET_ACCESS_KEY), |
| 400 | + aws_session_toxken=get_first_property_value(self._properties, AWS_SESSION_TOKEN), |
| 401 | + ) |
393 | 402 |
|
394 | 403 | def add_headers(self, request: PreparedRequest, **kwargs: Any) -> None: # pylint: disable=W0613 |
395 | | - boto_session = boto3.Session() |
396 | | - credentials = boto_session.get_credentials().get_frozen_credentials() |
397 | | - region = self._properties.get(SIGV4_REGION, boto_session.region_name) |
| 404 | + credentials = self._boto_session.get_credentials().get_frozen_credentials() |
| 405 | + region = self._properties.get(SIGV4_REGION, self._boto_session.region_name) |
398 | 406 | service = self._properties.get(SIGV4_SERVICE, "execute-api") |
399 | 407 |
|
400 | 408 | url = str(request.url).split("?")[0] |
|
0 commit comments