-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Allow string in addition to DatasetReference / TableReference in Clie… #6164
Conversation
…nt methods. Whereever a client method accepts a DatasetReference or TableReference, it now also accepts a string. The project ID can be omitted from the string and the Client's default project is used instead. Also, to make it easier to share code across client methods for creating XReference classes: * Add default_project argument to DatasetReference.from_string * Add default_project argument to TableReference.from_string
|
||
if isinstance(destination, str): | ||
destination = TableReference.from_string( | ||
destination, default_project=self.project) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Thank you @tseaver ! I find this far more pythonic and easier to use (e.g. the proportion of instances I'll use the API without pulling up the docs is much higher). Interested what others think. |
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.
Awesome!
:type retry: :class:`google.api_core.retry.Retry` | ||
:param retry: (Optional) How to retry the RPC. | ||
Args: | ||
dataset_ref (Union[ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@dpebot merge when green |
Okay! I'll merge when all statuses are green and all reviewers approve. |
…nt methods.
Whereever a client method accepts a DatasetReference or TableReference,
it now also accepts a string. The project ID can be omitted from the
string and the Client's default project is used instead.
Also, to make it easier to share code across client methods for creating
XReference classes:
Towards #6055. Not closes because we should add similar logic to the
create_dataset
andcreate_table
methods, but they need to be modified to also accept a reference. My thought there is that we can create an empty table/dataset resource when a string or reference is passed in.@max-sixty Please take a look.