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: added methods for getting keys, items and dict#4393

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

Merged
tswast merged 15 commits intogoogleapis:masterfromjosefbarta:patch-1
Nov 17, 2017

Conversation

@josefbarta
Copy link
Contributor

This change enables to retrieve the row as a dict and iterate the keys and/or items, like with a normal dict; in other words, making the Row object a dict-like object:

row.dict()
{'name': 'Isabel', 'profession': 'bridge builder'}
for k, v in row.items():
for k in row.keys():

This change enables to retrieve the row as a dict and iterate the keys and/or items, like with a normal dict; in other words, making the Row object a dict-like object:>>> row.dict(){'name': 'Isabel', 'profession': 'bridge builder'}>>> for k, v in row.items():>>> for k in row.keys():
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝Please visithttps://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g.I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Checkyour existing CLA data and verify that youremail is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@googlebotgooglebot added the cla: noThis human has *not* signed the Contributor License Agreement. labelNov 14, 2017
@josefbarta
Copy link
ContributorAuthor

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@googlebotgooglebot added cla: yesThis human has signed the Contributor License Agreement. and removed cla: noThis human has *not* signed the Contributor License Agreement. labelsNov 14, 2017
@dhermes
Copy link
Contributor

I'd like to do a thorough review of the code (e.g.keys() anditems() could be generators) but want to wait until@tswast comments on whether or not these features are desired.

@josefbarta
Copy link
ContributorAuthor

I see, good point about the generators, thanks. I'd fix that but will hold off until we know more about whether these are desirable at all. The thing is that it would be great to be able to either return the row as a dict or convert it to a dict really easily, which currently is a bit of a hacky process. Thanks!

@josefbarta
Copy link
ContributorAuthor

I fixed it after all; the tests seem to have run successfully :-)

@chemelnucfinchemelnucfin changed the titleadded methods for getting keys, items and dictBigQuery: added methods for getting keys, items and dictNov 14, 2017
@chemelnucfinchemelnucfin added the api: bigqueryIssues related to the BigQuery API. labelNov 14, 2017
@tseavertseaver requested a review fromtswastNovember 15, 2017 20:42
@tswast
Copy link
Contributor

I likekeys() anditems() to makeRow act even more like a dictionary. That part LGTM.

What is your desired use fordict()? Are you using it to serialize the rows?

@josefbarta
Copy link
ContributorAuthor

I'm usingdict() to serialise rows into a standard dict, which I can then convert to json. As long askeys() and/oritems() makes it in, I'm happy not to havedict(), simply because I can do it in my own code. Alternatively, I'm happy to write aget() method forRow instead, so it's possible to get a value in a dict-standard failsafe way. Thanks!

@tswast
Copy link
Contributor

As long askeys() and/oritems() makes it in, I'm happy not to havedict().

Yeah, I'd prefer not to havedict() since it's not a standard method and it's easy enough for someone to make their own dictionary now that there iskeys() anditems().

Alternatively, I'm happy to write a get() method for Row instead, so it's possible to get a value in a dict-standard failsafe way. Thanks!

Ooh, yes please to adding theget() method. That sounds great.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@googlebotgooglebot added cla: noThis human has *not* signed the Contributor License Agreement. and removed cla: yesThis human has signed the Contributor License Agreement. labelsNov 17, 2017
@josefbarta
Copy link
ContributorAuthor

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@googlebotgooglebot added cla: yesThis human has signed the Contributor License Agreement. and removed cla: noThis human has *not* signed the Contributor License Agreement. labelsNov 17, 2017
@josefbarta
Copy link
ContributorAuthor

Sodict() is now removed andget() is in place, including code checks and the tests for the module check out (not yet completed for the whole hog but that should be fine). Please let me know if there are any issues with my code I should fix. Thanks!

''
"""
index=self._xxx_field_to_index.get(key)
ifindexisNone:

This comment was marked as spam.

This comment was marked as spam.

Copy link
Contributor

@tswasttswast left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

@tswasttswast merged commite89ab7e intogoogleapis:masterNov 17, 2017
@josefbarta
Copy link
ContributorAuthor

Thanks :-)

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

Reviewers

@tswasttswasttswast approved these changes

@lukesneeringerlukesneeringerAwaiting requested review from lukesneeringer

Assignees

No one assigned

Labels

api: bigqueryIssues related to the BigQuery API.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.

6 participants

@josefbarta@googlebot@dhermes@tswast@chemelnucfin@josef-artlogic

[8]ページ先頭

©2009-2025 Movatter.jp