Skip to content
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

Merged
merged 2 commits into from
Oct 4, 2018

Conversation

tswast
Copy link
Contributor

@tswast tswast commented Oct 4, 2018

…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

Towards #6055. Not closes because we should add similar logic to the create_dataset and create_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.

…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
@tswast tswast requested a review from theacodes as a code owner October 4, 2018 15:27
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 4, 2018

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.

@max-sixty
Copy link

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.

Copy link
Contributor

@alixhami alixhami left a 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.

@tswast
Copy link
Contributor Author

tswast commented Oct 4, 2018

@dpebot merge when green

@dpebot
Copy link
Contributor

dpebot commented Oct 4, 2018

Okay! I'll merge when all statuses are green and all reviewers approve.

@dpebot dpebot added the automerge Merge the pull request once unit tests and other checks pass. label Oct 4, 2018
@dpebot dpebot self-assigned this Oct 4, 2018
@tswast tswast merged commit 93d5ea2 into googleapis:master Oct 4, 2018
@tswast tswast deleted the issue-6055-dataset-table-ref branch October 4, 2018 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge the pull request once unit tests and other checks pass. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants