Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BigQuery: Add list rows and --max_results option to %%bigquery magic#9147

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@shubha-rajan
Copy link
Contributor

@shubha-rajanshubha-rajan commentedAug 29, 2019
edited
Loading

See#9105. Creating draft for visibility.

Adds option to pass a table id instead of a SQL query to%%bigquery cell magic as a cost-saving alternative toSELECT * queries.--max_results option limits the number of rows read. The returnedpandas.DataFrame can be saved to a variable by passing adestination_var argument.

image

TODO:

  • Fix coverage failures

  • Test that running cell magic with table ID instead of query works withbqstorage_client set

  • Add tests for failure cases- handles failure cases when table IDs are passed instead of queries:
    image

  • max_results is currently not working with regular SQL queries - fixed! See screenshot below
    image

To get this working, I ended up addingmax_results as a property ofQueryJobConfig, but if that wasn't the right call, I can refactor to passmax_results as a separate parameter.

@googlebotgooglebot added the cla: yesThis human has signed the Contributor License Agreement. labelAug 29, 2019
:type api_response: dict
:paramapi_response: response returned from an API call
Args:
api_response (dict): response returned from an API call.
Copy link
Contributor

@plamutplamutAug 30, 2019
edited
Loading

Choose a reason for hiding this comment

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

By the way, the types are specified with names from thetyping module, thus adict should be namedDict, for example. OrDict[key_type, value_type] if you also want to specify the dict content's type(s). Probably best to check some of the existing "modern" docstrings in the codebase to get a feel.

shubha-rajan reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

got it. Thedict in question would be a nested API response so it would be okay to just name itDict without specifying the content, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose so, yes. If all keys are strings,Dict[str, Any] could be used, but justDict with a meaningful description is fine, too.

@shubha-rajan
Copy link
ContributorAuthor

failing snippets tests also fail locally on master, so they're probably unrelated to changes in this PR

@shubha-rajanshubha-rajan marked this pull request as ready for reviewAugust 30, 2019 21:55
@shubha-rajanshubha-rajan requested a review froma teamAugust 30, 2019 21:55
@plamut
Copy link
Contributor

@shubha-rajan Indeed, that started occurring a day or two ago. The backend team has been informed about it, we are awaiting the ETA for the fix. If it's too long, we can temporarily disable the failing test as a workaround.

@tswast
Copy link
Contributor

Since these are two different features, let's have them as two (possibly 3) separate PRs, starting with--max_results feature. That way they are more clearly identified as new features in the CHANGELOG when we release these features.

I'd prefer we find a different implementation formax_results. Note:list_rowsaccepts amax_results argument, andQueryJob.resultcalls thelist_rows method. I think it would be appropriate to add amax_results argument toQueryJob.result.

Let's have 3 PRs in this order:

  1. Addmax_results=None argument to theQueryJob.result method.
  2. Add a--max_results argument to the%%bigquery magic.
  3. Add ability to pass in a table ID instead of a query to the%%bigquery magic.
shubha-rajan reacted with thumbs up emoji

@shubha-rajan
Copy link
ContributorAuthor

@tswast sounds good. I'll close this one and submit 3 separate PRs

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@plamutplamutplamut left review comments

@IlyaFaerIlyaFaerIlyaFaer left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@shubha-rajan@plamut@tswast@IlyaFaer@googlebot

[8]ページ先頭

©2009-2025 Movatter.jp