-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement pre-existing session support for dynamodb catalog #104
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -80,7 +80,15 @@ | |||||||||||||||||||||||||||||||||||||
class DynamoDbCatalog(Catalog): | ||||||||||||||||||||||||||||||||||||||
def __init__(self, name: str, **properties: str): | ||||||||||||||||||||||||||||||||||||||
super().__init__(name, **properties) | ||||||||||||||||||||||||||||||||||||||
self.dynamodb = boto3.client(DYNAMODB_CLIENT) | ||||||||||||||||||||||||||||||||||||||
session = boto3.Session( | ||||||||||||||||||||||||||||||||||||||
profile_name=properties.get("profile_name"), | ||||||||||||||||||||||||||||||||||||||
region_name=properties.get("region_name"), | ||||||||||||||||||||||||||||||||||||||
botocore_session=properties.get("botocore_session"), | ||||||||||||||||||||||||||||||||||||||
aws_access_key_id=properties.get("aws_access_key_id"), | ||||||||||||||||||||||||||||||||||||||
aws_secret_access_key=properties.get("aws_secret_access_key"), | ||||||||||||||||||||||||||||||||||||||
aws_session_token=properties.get("aws_session_token"), | ||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||
self.dynamodb = session.client(DYNAMODB_CLIENT) | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we add a unit test for this update? Like this one in GlueCatalog's test: iceberg-python/tests/catalog/test_glue.py Lines 442 to 459 in d8bc9a9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @HonahX , thanks for the suggestion. I added the unit test as you requested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding the test! |
||||||||||||||||||||||||||||||||||||||
self.dynamodb_table_name = self.properties.get(DYNAMODB_TABLE_NAME, DYNAMODB_TABLE_NAME_DEFAULT) | ||||||||||||||||||||||||||||||||||||||
self._ensure_catalog_table_exists_or_create() | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
|
@@ -110,7 +118,7 @@ def _dynamodb_table_exists(self) -> bool: | |||||||||||||||||||||||||||||||||||||
return False | ||||||||||||||||||||||||||||||||||||||
except self.dynamodb.exceptions.InternalServerError as e: | ||||||||||||||||||||||||||||||||||||||
raise GenericDynamoDbError(e.message) from e | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
print(response["Table"]["TableStatus"]) | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: could you please remove this print? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a nit at all, thanks for the catch |
||||||||||||||||||||||||||||||||||||||
if response["Table"]["TableStatus"] != ACTIVE: | ||||||||||||||||||||||||||||||||||||||
raise GenericDynamoDbError(f"DynamoDB table for catalog {self.dynamodb_table_name} is not {ACTIVE}") | ||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that we're mixing case here 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah.. i mean the underscores are pretty typical aws syntax but iceberg has always used hyphens afaik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have an inconsistency since the FileIO configurations use hyphens for s3 credentials:
iceberg-python/mkdocs/docs/configuration.md
Lines 66 to 67 in d8bc9a9
Also, what about adding a
dynamo.
prefix to these credential keys?This could help clarify that these keys are used exclusively by the catalog, not the FileIO:
Just thinking ahead, if we're in favor of renaming these configurations, perhaps it's something we could roll out in a separate PR, especially considering updates to the GlueCatalog configurations that would follow.
I'd love to hear your thoughts on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HonahX Definitely agreed with
dynamo
as a prefix.As for hyphens vs underscores, AWS is really consistent about using underscores. I'm of the opinion that the AWS-based credentials should support both underscores and hyphens, will prefer hyphens if present, but fall back to the underscore usages if necessary. Documentation should only present the hyphenated case as an option. I believe that this strategy would lead to the least number of "head banging" debug sessions. However, I think a reasonable case could be made to remove underscore support instead of supporting it as a fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waifairer Yes, I totally agree. Let's do that in a separate PR.