-
Notifications
You must be signed in to change notification settings - Fork 422
Check storage-credentials before config in table response #2600
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
Open
coca-alex
wants to merge
9
commits into
apache:main
Choose a base branch
from
coca-alex:fix-storage-credential
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
be91f8a
Check storage-credentials before config in table response
c55eecc
Check storage-credentials before config in table response
e309dea
rollback ruff changes
59dfe20
fix storage credentials type
d98327c
fix condition
a64bcd4
fix: choosing the most specific prefix for storage credentials
4a080ef
add signing commit
656b07d
add signing commit
b16b2af
fix: lintering
coca-alex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,10 +152,16 @@ def _retry_hook(retry_state: RetryCallState) -> None: | |
| } | ||
|
|
||
|
|
||
| class StorageCredential(IcebergBaseModel): | ||
| prefix: str = Field() | ||
| config: Properties = Field() | ||
|
|
||
|
|
||
| class TableResponse(IcebergBaseModel): | ||
| metadata_location: Optional[str] = Field(alias="metadata-location", default=None) | ||
| metadata: TableMetadata | ||
| config: Properties = Field(default_factory=dict) | ||
| storage_credentials: Optional[List[StorageCredential]] = Field(alias="storage-credentials", default=None) | ||
|
|
||
|
|
||
| class CreateTableRequest(IcebergBaseModel): | ||
|
|
@@ -454,7 +460,16 @@ def _response_to_table(self, identifier_tuple: Tuple[str, ...], table_response: | |
| metadata_location=table_response.metadata_location, # type: ignore | ||
| metadata=table_response.metadata, | ||
| io=self._load_file_io( | ||
| {**table_response.metadata.properties, **table_response.config}, table_response.metadata_location | ||
| { | ||
| **table_response.metadata.properties, | ||
| **self._get_credentials( | ||
| table_response.storage_credentials, | ||
| table_response.config, | ||
| table_response.metadata_location, | ||
| getattr(table_response.metadata, "location", None), | ||
| ), | ||
| }, | ||
| table_response.metadata_location, | ||
| ), | ||
| catalog=self, | ||
| config=table_response.config, | ||
|
|
@@ -466,11 +481,42 @@ def _response_to_staged_table(self, identifier_tuple: Tuple[str, ...], table_res | |
| metadata_location=table_response.metadata_location, # type: ignore | ||
| metadata=table_response.metadata, | ||
| io=self._load_file_io( | ||
| {**table_response.metadata.properties, **table_response.config}, table_response.metadata_location | ||
| { | ||
| **table_response.metadata.properties, | ||
| **self._get_credentials( | ||
| table_response.storage_credentials, | ||
| table_response.config, | ||
| table_response.metadata_location, | ||
| getattr(table_response.metadata, "location", None), | ||
|
Contributor
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. i wonder if its necessary to include the "metadata location" here as a fallback; or just always use |
||
| ), | ||
| }, | ||
| table_response.metadata_location, | ||
| ), | ||
| catalog=self, | ||
| ) | ||
|
|
||
| @staticmethod | ||
| def _get_credentials( | ||
| storage_credentials: Optional[List[StorageCredential]], | ||
| config: Properties, | ||
| metadata_location: Optional[str], | ||
| table_location: Optional[str], | ||
| ) -> Properties: | ||
| if not storage_credentials: | ||
| return config | ||
|
|
||
| target = metadata_location or table_location | ||
| if not target: | ||
| return config | ||
|
|
||
| # Choose the most specific (longest) matching prefix | ||
| matching: List[StorageCredential] = [sc for sc in storage_credentials if target.startswith(sc.prefix)] | ||
| if not matching: | ||
| return config | ||
|
|
||
| selected = max(matching, key=lambda sc: len(sc.prefix)) | ||
| return selected.config | ||
|
|
||
| def _refresh_token(self) -> None: | ||
| # Reactive token refresh is atypical - we should proactively refresh tokens in a separate thread | ||
| # instead of retrying on Auth Exceptions. Keeping refresh behavior for the LegacyOAuth2AuthManager | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: might be easier to just just List here