This repository was archived by the owner on Mar 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 324
feat: accept TableListItem where TableReference is accepted #1016
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5bcaa92
feat: accept TableListItem where TableReference is accepted
steffnay f830a02
Merge branch 'main' of github.com:googleapis/python-bigquery into acc…
steffnay 297f9a3
update unit test
steffnay eca2789
Merge branch 'main' into accept-TLI
steffnay 0c1214b
Merge branch 'main' into accept-TLI
steffnay 9467abc
remove raise
steffnay 8775658
Merge branch 'main' into accept-TLI
steffnay 86f7c87
Merge branch 'main' into accept-TLI
steffnay 9b6c908
Merge branch 'main' into accept-TLI
tswast 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 |
|---|---|---|
|
|
@@ -806,13 +806,16 @@ def get_dataset( | |
|
|
||
| def get_iam_policy( | ||
| self, | ||
| table: Union[Table, TableReference], | ||
| table: Union[Table, TableReference, TableListItem, str], | ||
| requested_policy_version: int = 1, | ||
| retry: retries.Retry = DEFAULT_RETRY, | ||
| timeout: float = DEFAULT_TIMEOUT, | ||
| ) -> Policy: | ||
| if not isinstance(table, (Table, TableReference)): | ||
| raise TypeError("table must be a Table or TableReference") | ||
| table = _table_arg_to_table_ref(table, default_project=self.project) | ||
| if not isinstance(table, (TableReference)): | ||
| raise TypeError( | ||
| "table must be a Table, TableReference, or TableListItem, or string" | ||
| ) | ||
|
|
||
| if requested_policy_version != 1: | ||
| raise ValueError("only IAM policy version 1 is supported") | ||
|
|
@@ -835,14 +838,17 @@ def get_iam_policy( | |
|
|
||
| def set_iam_policy( | ||
| self, | ||
| table: Union[Table, TableReference], | ||
| table: Union[Table, TableReference, TableListItem, str], | ||
| policy: Policy, | ||
| updateMask: str = None, | ||
| retry: retries.Retry = DEFAULT_RETRY, | ||
| timeout: float = DEFAULT_TIMEOUT, | ||
| ) -> Policy: | ||
| if not isinstance(table, (Table, TableReference)): | ||
| raise TypeError("table must be a Table or TableReference") | ||
| table = _table_arg_to_table_ref(table, default_project=self.project) | ||
| if not isinstance(table, (TableReference)): | ||
| raise TypeError( | ||
|
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. Line not covered in unit tests
Contributor
Author
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. Ah, got it! Thanks! |
||
| "table must be a Table, TableReference, or TableListItem, or string" | ||
| ) | ||
|
|
||
| if not isinstance(policy, (Policy)): | ||
| raise TypeError("policy must be a Policy") | ||
|
|
@@ -869,13 +875,16 @@ def set_iam_policy( | |
|
|
||
| def test_iam_permissions( | ||
| self, | ||
| table: Union[Table, TableReference], | ||
| table: Union[Table, TableReference, TableListItem, str], | ||
| permissions: Sequence[str], | ||
| retry: retries.Retry = DEFAULT_RETRY, | ||
| timeout: float = DEFAULT_TIMEOUT, | ||
| ) -> Dict[str, Any]: | ||
| if not isinstance(table, (Table, TableReference)): | ||
| raise TypeError("table must be a Table or TableReference") | ||
| table = _table_arg_to_table_ref(table, default_project=self.project) | ||
| if not isinstance(table, (TableReference)): | ||
| raise TypeError( | ||
|
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. Line not covered in unit tests |
||
| "table must be a Table, TableReference, or TableListItem, or string" | ||
| ) | ||
|
|
||
| body = {"permissions": permissions} | ||
|
|
||
|
|
@@ -982,7 +991,7 @@ def get_routine( | |
|
|
||
| def get_table( | ||
| self, | ||
| table: Union[Table, TableReference, str], | ||
| table: Union[Table, TableReference, TableListItem, str], | ||
| retry: retries.Retry = DEFAULT_RETRY, | ||
| timeout: float = DEFAULT_TIMEOUT, | ||
| ) -> Table: | ||
|
|
@@ -992,6 +1001,7 @@ def get_table( | |
| table (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| ]): | ||
| A reference to the table to fetch from the BigQuery API. | ||
|
|
@@ -1757,7 +1767,7 @@ def delete_routine( | |
|
|
||
| def delete_table( | ||
| self, | ||
| table: Union[Table, TableReference, str], | ||
| table: Union[Table, TableReference, TableListItem, str], | ||
| retry: retries.Retry = DEFAULT_RETRY, | ||
| timeout: float = DEFAULT_TIMEOUT, | ||
| not_found_ok: bool = False, | ||
|
|
@@ -1771,6 +1781,7 @@ def delete_table( | |
| table (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| ]): | ||
| A reference to the table to delete. If a string is passed in, | ||
|
|
@@ -2257,7 +2268,7 @@ def api_request(*args, **kwargs): | |
| def load_table_from_uri( | ||
| self, | ||
| source_uris: Union[str, Sequence[str]], | ||
| destination: Union[Table, TableReference, str], | ||
| destination: Union[Table, TableReference, TableListItem, str], | ||
| job_id: str = None, | ||
| job_id_prefix: str = None, | ||
| location: str = None, | ||
|
|
@@ -2278,6 +2289,7 @@ def load_table_from_uri( | |
| destination (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| ]): | ||
| Table into which data is to be loaded. If a string is passed | ||
|
|
@@ -2339,7 +2351,7 @@ def load_table_from_uri( | |
| def load_table_from_file( | ||
| self, | ||
| file_obj: BinaryIO, | ||
| destination: Union[Table, TableReference, str], | ||
| destination: Union[Table, TableReference, TableListItem, str], | ||
| rewind: bool = False, | ||
| size: int = None, | ||
| num_retries: int = _DEFAULT_NUM_RETRIES, | ||
|
|
@@ -2360,6 +2372,7 @@ def load_table_from_file( | |
| destination (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| ]): | ||
| Table into which data is to be loaded. If a string is passed | ||
|
|
@@ -2699,7 +2712,7 @@ def load_table_from_dataframe( | |
| def load_table_from_json( | ||
| self, | ||
| json_rows: Iterable[Dict[str, Any]], | ||
| destination: Union[Table, TableReference, str], | ||
| destination: Union[Table, TableReference, TableListItem, str], | ||
| num_retries: int = _DEFAULT_NUM_RETRIES, | ||
| job_id: str = None, | ||
| job_id_prefix: str = None, | ||
|
|
@@ -2733,6 +2746,7 @@ def load_table_from_json( | |
| destination (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| ]): | ||
| Table into which data is to be loaded. If a string is passed | ||
|
|
@@ -2980,9 +2994,13 @@ def _do_multipart_upload( | |
| def copy_table( | ||
| self, | ||
| sources: Union[ | ||
| Table, TableReference, str, Sequence[Union[Table, TableReference, str]] | ||
| Table, | ||
| TableReference, | ||
| TableListItem, | ||
| str, | ||
| Sequence[Union[Table, TableReference, TableListItem, str]], | ||
| ], | ||
| destination: Union[Table, TableReference, str], | ||
| destination: Union[Table, TableReference, TableListItem, str], | ||
| job_id: str = None, | ||
| job_id_prefix: str = None, | ||
| location: str = None, | ||
|
|
@@ -3000,11 +3018,13 @@ def copy_table( | |
| sources (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| Sequence[ \ | ||
| Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| ] \ | ||
| ], \ | ||
|
|
@@ -3013,6 +3033,7 @@ def copy_table( | |
| destination (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| ]): | ||
| Table into which data is to be copied. | ||
|
|
@@ -3084,7 +3105,7 @@ def copy_table( | |
|
|
||
| def extract_table( | ||
| self, | ||
| source: Union[Table, TableReference, Model, ModelReference, str], | ||
| source: Union[Table, TableReference, TableListItem, Model, ModelReference, str], | ||
| destination_uris: Union[str, Sequence[str]], | ||
| job_id: str = None, | ||
| job_id_prefix: str = None, | ||
|
|
@@ -3104,6 +3125,7 @@ def extract_table( | |
| source (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| google.cloud.bigquery.model.Model, \ | ||
| google.cloud.bigquery.model.ModelReference, \ | ||
| src, \ | ||
|
|
@@ -3465,7 +3487,7 @@ def insert_rows_from_dataframe( | |
|
|
||
| def insert_rows_json( | ||
| self, | ||
| table: Union[Table, TableReference, str], | ||
| table: Union[Table, TableReference, TableListItem, str], | ||
| json_rows: Sequence[Dict], | ||
| row_ids: Union[Iterable[str], AutoRowIDs, None] = AutoRowIDs.GENERATE_UUID, | ||
| skip_invalid_rows: bool = None, | ||
|
|
@@ -3483,6 +3505,7 @@ def insert_rows_json( | |
| table (Union[ \ | ||
| google.cloud.bigquery.table.Table \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str \ | ||
| ]): | ||
| The destination table for the row data, or a reference to it. | ||
|
|
@@ -3605,7 +3628,7 @@ def insert_rows_json( | |
|
|
||
| def list_partitions( | ||
| self, | ||
| table: Union[Table, TableReference, str], | ||
| table: Union[Table, TableReference, TableListItem, str], | ||
| retry: retries.Retry = DEFAULT_RETRY, | ||
| timeout: float = DEFAULT_TIMEOUT, | ||
| ) -> Sequence[str]: | ||
|
|
@@ -3615,6 +3638,7 @@ def list_partitions( | |
| table (Union[ \ | ||
| google.cloud.bigquery.table.Table, \ | ||
| google.cloud.bigquery.table.TableReference, \ | ||
| google.cloud.bigquery.table.TableListItem, \ | ||
| str, \ | ||
| ]): | ||
| The table or reference from which to get partition info | ||
|
|
||
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
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.
Need unit test that covers this. Possibly this if statement can be deleted if
_table_arg_to_table_refalready throws?