-
Notifications
You must be signed in to change notification settings - Fork 322
refactor: update insert_rows.py for more efficient streaming #212
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
Conversation
dd0f632 to
b842fb5
Compare
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.
Please rebase to remove the release-related changes from this PR (the first three commits). Oops, my bad: the issue is that your PR targets the release-v1.27.0 branch, instead of master.
Ahh, sorry about that. I don't submit code very often :/. Should I make a new PR against master instead? |
|
I re-based this off of the master branch, now it just needs the files added by the chore bot to be removed. Doesn't look like I have rights to do that though. |
|
@jmgreger If you use $ git checkout master
$ git fetch --all upstream # assuming this repo's remote is named 'upstream'.
$ git pull upstream/master
$ git checkout patch-1
$ git rebase -i master # delete first three commits and the last merge commit
$ git push -f origin patch-1As an alternative, you could just cherry-pick the patch from this commit into a new branch against current master, and then submit a new PR from that branch. |
| rows_to_insert = [(u"Phred Phlyntstone", 32), (u"Wylma Phlyntstone", 29)] #populate data for entry | ||
|
|
||
| try: | ||
| if 'schema' not in globals(): |
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.
Please keep the sample simple. This is unnecessary branching. If anything, we can call out that the schema can be fetched from a table in a comment.
| client.insert_rows(table_id, selected_fields=schema, rows_to_insert) # Stream data to BQ | ||
| print("New rows have been added.") | ||
| except ValueError: | ||
| print("Table’s schema is not set or rows is not a Sequence.") |
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.
No need to catch this ValueError. Just let the exception bubble up.
|
LGTM once Tim's comments are addressed and as long as tests pass |
Added in the use of selected_fields=schema to explicitly define the schema. This prevents excessive calling of table metadata when streaming large volumes of data. There may be a better way to showcase this in the code, but I wanted to put this out there for review.
…eapis#208) Co-authored-by: Tres Seaver <[email protected]> Co-authored-by: Takashi Matsuo <[email protected]>
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
Co-authored-by: Tim Swast <[email protected]>
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
Closing this in favor of #253 as per comment in that PR. |
Added in the use of selected_fields=schema to explicitly define the schema. This prevents excessive calling of table metadata when streaming large volumes of data.
There may be a better way to showcase this in the code, but I wanted to put this out there for review.
Fixes #211 🦕