Uh oh!
There was an error while loading. Please reload this page.
Robustify boto3 session handling (DynamoDB, RestCatalog) - #2071
Conversation
| def __init__(self, **properties: str): | ||
| super().__init__() | ||
| self._properties = properties | ||
| self._boto_session = boto3.Session( | ||
| region_name=get_first_property_value(self._properties, AWS_REGION), | ||
| botocore_session=self._properties.get(BOTOCORE_SESSION), | ||
| aws_access_key_id=get_first_property_value(self._properties, AWS_ACCESS_KEY_ID), | ||
| aws_secret_access_key=get_first_property_value(self._properties, AWS_SECRET_ACCESS_KEY), | ||
| aws_session_toxken=get_first_property_value(self._properties, AWS_SESSION_TOKEN), | ||
| ) | ||
| def add_headers(self, request: PreparedRequest, **kwargs: Any) -> None: # pylint: disable=W0613 | ||
| boto_session = boto3.Session() | ||
| credentials = boto_session.get_credentials().get_frozen_credentials() | ||
| region = self._properties.get(SIGV4_REGION, boto_session.region_name) |
There was a problem hiding this comment.
@Fokko@kevinjqliu probably worth refactoring this class out to get some proper test coverage?
There was a problem hiding this comment.
Hey @jayceslesar yes, I think that makes sense. Let's do that in a separate PR 👍
rudolfix
commented
Jun 9, 2025
thx for working on this :) |
Uh oh!
There was an error while loading. Please reload this page.
| glue = ["boto3", "mypy-boto3-glue"] | ||
| adlfs = ["adlfs"] | ||
| dynamodb = ["boto3"] | ||
| dynamodb = ["boto3", "mypy-boto3-dynamodb"] |
There was a problem hiding this comment.
Shouldn't this be a dev-dependency?
There was a problem hiding this comment.
probably -- the glue one isnt but I will move both over
| ) | ||
| self.dynamodb = session.client(DYNAMODB_CLIENT) | ||
| self.dynamodb_table_name = self.properties.get(DYNAMODB_TABLE_NAME, DYNAMODB_TABLE_NAME_DEFAULT) | ||
| self._ensure_catalog_table_exists_or_create() |
There was a problem hiding this comment.
Do we want to execute this when passing in an existing client?
| aws_session_token=get_first_property_value(properties, DYNAMODB_SESSION_TOKEN, AWS_SESSION_TOKEN), | ||
| ) | ||
| self.dynamodb = session.client(DYNAMODB_CLIENT) | ||
| self.dynamodb_table_name = self.properties.get(DYNAMODB_TABLE_NAME, DYNAMODB_TABLE_NAME_DEFAULT) |
There was a problem hiding this comment.
I think we also want to assign this one when passing in an existing client. Adding the methods to the class for completeness may also be a good thing to do as part of this PR.
There was a problem hiding this comment.
I think they do exist (in the MetastoreCatalog) and were just never updated into this class. I will take a look
There was a problem hiding this comment.
After a second look I dont know if we need to make a change _ensure_catalog_table_exists_or_create makes the dynamo table which is needed to make + interact with iceberg tables
Co-authored-by: Marko Grujic <markoog@gmail.com>
CharlesAttend
commented
Jun 10, 2025
Thank you for fixing this! |
Fokko
left a comment
There was a problem hiding this comment.
Thanks again @jayceslesar for working on this, one minor comment that needs to be addressed, but apart from that, this looks great 🥳
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| version = "2.44.0" | ||
| version = "2.46.0" |
There was a problem hiding this comment.
Maybe need to add
"ignore::ResourceWarning",
"ignore::pytest.PytestUnraisableExceptionWarning",
To filterwarnings? idrk
There was a problem hiding this comment.
Ideally, we don't want to bump Ray as part of this PR. Maybe add the <=2.44.0 constraint to Ray for now?
Fokko
commented
Jun 11, 2025
Finally green, thanks @jayceslesar for working on this 🙌 |
3 changes here... 1. Basically a mirror of apache#1920 but for dynamo 2. Allow users to pass in an existing client/pass initialize client with properties in `RestCatalog` with sigv4 enabled. (closesapache#2070, closesapache#2008) 3. Re-use of the client in `add_headers` in `RestCatalog` with sigv4. (closesapache#2069 ) --------- Co-authored-by: Marko Grujic <markoog@gmail.com>
3 changes here... 1. Basically a mirror of apache#1920 but for dynamo 2. Allow users to pass in an existing client/pass initialize client with properties in `RestCatalog` with sigv4 enabled. (closesapache#2070, closesapache#2008) 3. Re-use of the client in `add_headers` in `RestCatalog` with sigv4. (closesapache#2069 ) --------- Co-authored-by: Marko Grujic <markoog@gmail.com>
3 changes here...
RestCatalogwith sigv4 enabled. (closesRestCatalogwith sigv4 enabled doesn't pick up creds provided as arguments #2070, closesAllow to pass botocore session to REST Catalog (S3 Tables) like Glue Catalog does #2008)add_headersinRestCatalogwith sigv4. (closesRestCatalogwith sigv4 enabled instantiates a boto session per each client call #2069 )