Skip to content

Allow string in addition to DatasetReference / TableReference in Clie…#6164

Merged
tswast merged 2 commits into
googleapis:masterfrom
tswast:issue-6055-dataset-table-ref
Oct 4, 2018
Merged

Allow string in addition to DatasetReference / TableReference in Clie…#6164
tswast merged 2 commits into
googleapis:masterfrom
tswast:issue-6055-dataset-table-ref

Conversation

@tswast

@tswast tswast commented Oct 4, 2018

Copy link
Copy Markdown
Contributor

…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 review from alixhami and tseaver October 4, 2018 15:27
@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
Copy Markdown
Contributor

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.

@alixhami alixhami left a comment

Copy link
Copy Markdown
Contributor

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

tswast commented Oct 4, 2018

Copy link
Copy Markdown
Contributor Author

@dpebot merge when green

@dpebot

dpebot commented Oct 4, 2018

Copy link
Copy Markdown
Contributor

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 removed request for theacodes and tseaver October 4, 2018 20:04
@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.

5 participants