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

feat(bigquery): add create_bqstorage_client param to to_dataframe and to_arrow #9573

Merged
merged 6 commits into from
Dec 17, 2019

Conversation

tswast
Copy link
Contributor

@tswast tswast commented Oct 30, 2019

When the create_bqstorage_client parameter is set to True, the BigQuery
client constructs a BigQuery Storage API client for you. This removes
the need for boilerplate code to manually construct both clients
explicitly with the same credentials.

Does this make the bqstorage_client parameter unnecessary? In most
cases, yes, but there are a few cases where we'll want to continue using
it. Specifically, when partner tools use to_dataframe, they should
continue to use bqstorage_client so that they can set the correct
amended user-agent strings. bqstorage_client is also needed for regional
API endpoints.

TODO

  • Add owns_bqstorage_client to track if bqstorage_client needs its transport closed.
  • Add try/finally block where finally closes the transport only if owns_bqstorage_client is true.
  • Test that client is not created if max_results is set.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 30, 2019
@shollyman
Copy link
Contributor

feedback during informal review: be clearer we're only using default settings when constructing the client on user behalf, and that to do more you'll still want to supply your own client.

@tswast tswast changed the title feat(bigquery): add use_bqstorage_api param to to_dataframe and `… feat(bigquery): add create_bqstorage_client param to to_dataframe and to_arrow Nov 1, 2019
@tswast tswast marked this pull request as ready for review November 1, 2019 22:41
@tswast tswast requested review from a team, plamut and shollyman November 1, 2019 22:41
Copy link
Contributor

@plamut plamut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I only have a few minor comments.

Making it more clear that auto-creating a BQ storage client behind the scenes only uses the default settings would indeed be beneficial, as @shollyman pointed out.

@tswast tswast requested a review from plamut November 4, 2019 22:10
Copy link
Contributor

@plamut plamut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

The remaining remark is trivial, feel free to ignore, as the linter appears to not bother.


download_public_data_sandbox.download_public_data_sandbox(client)
out, _ = capsys.readouterr()
out, err = capsys.readouterr()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err is not used anywhere?

@tswast
Copy link
Contributor Author

tswast commented Nov 5, 2019

Per #9457

I should close the client transport if we create it in the method.

@tswast tswast added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 9, 2019
@tswast tswast changed the title feat(bigquery): add create_bqstorage_client param to to_dataframe and to_arrow [DO NOT MERGE] feat(bigquery): add create_bqstorage_client param to to_dataframe and to_arrow Nov 9, 2019
… and `to_arrow`

When the `create_bqstorage_client` parameter is set to `True`, the
BigQuery client constructs a BigQuery Storage API client for you. This
removes the need for boilerplate code to manually construct both clients
explitly with the same credentials.

Does this make the `bqstorage_client` parameter unnecessary? In most
cases, yes, but there are a few cases where we'll want to continue using
it.

* When partner tools use `to_dataframe`, they should continue to use
  `bqstorage_client` so that they can set the correct amended user-agent
  strings.
* When a developer needs to override the default API endpoint for the BQ
  Storage API, they'll need to manually supply a `bqstorage_client`.
@tswast tswast changed the title [DO NOT MERGE] feat(bigquery): add create_bqstorage_client param to to_dataframe and to_arrow feat(bigquery): add create_bqstorage_client param to to_dataframe and to_arrow Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants