GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add 'Table.row_from_mapping' helper. by tseaver · Pull Request #3425 · googleapis/google-cloud-python

Conversation

@tseaver

@tseaver tseaver commented May 16, 2017

Copy link
Copy Markdown
Contributor

Closes #3396.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tseaver
Fix typo in mode name.
751abe9
@tseaver tseaver added api: bigquery Issues related to the BigQuery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels May 16, 2017
@tseaver
tseaver requested review from dhermes and theacodes May 16, 2017 19:20
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 16, 2017
dhermes
dhermes reviewed May 16, 2017
View reviewed changes

@dhermes dhermes left a comment

Copy link
Copy Markdown
Contributor

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.

I wouldn't say this "closes #3396". That asks us to accept dictionaries in insert_data.

We should either:

  • Explicitly not support it (i.e. either a blacklist or whitelist of types)
  • Accept a polymorphic input (I am not really into that)
  • Offer a sibling insert_data_from_mappings (or a better / shorter name)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread bigquery/google/cloud/bigquery/table.py

:rtype: tuple
:returns: Tuple matching the table's schema
:raises: ValueError if table's schema is not set

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread bigquery/google/cloud/bigquery/table.py Outdated
:param mapping: Mapping of row data.

:rtype: tuple
:returns: Tuple matching the table's schema

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread bigquery/google/cloud/bigquery/table.py Outdated
row.append(mapping[field.name])
elif field.mode == 'REPEATED':
row.append(mapping.get(field.name, ()))
else: # NULLABLE

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread bigquery/google/cloud/bigquery/table.py
row.append(mapping.get(field.name, ()))
else: # NULLABLE
row.append(mapping.get(field.name))
return tuple(row)

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread bigquery/tests/unit/test_table.py
with self.assertRaises(ValueError) as exc:
table.row_from_mapping(MAPPING)

self.assertEqual(exc.exception.args, (_TABLE_HAS_NO_SCHEMA,))

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented May 17, 2017

Copy link
Copy Markdown
Contributor Author

Given a row_from_mapping helper method, the insert_data_from_mappings one is redundant: it is the equivalent of:

table.insert_data([table.row_from_mapping(mapping) for mapping in mapping_list])

I'm proposing closing #3396 with a note to that effect.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver
Add 'Table.row_from_mapping' helper.
14d8431
Closes #3396.
@lukesneeringer

lukesneeringer commented Aug 7, 2017

Copy link
Copy Markdown
Contributor

@dhermes @tseaver This still seems to be in good shape. Can we merge it?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Aug 7, 2017

Copy link
Copy Markdown
Contributor

If LGTY @lukesneeringer then I'm OK with it

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lukesneeringer
lukesneeringer merged commit 1b764b8 into googleapis:master Aug 7, 2017
@tseaver
tseaver deleted the 3396-bigquery-row_from_mapping branch August 10, 2017 18:13
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 21, 2017
@tseaver @landrito
Add 'Table.row_from_mapping' helper. (googleapis#3425)
88ccc6f
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
@tseaver @landrito
Add 'Table.row_from_mapping' helper. (googleapis#3425)
0b54db2
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
@tseaver @landrito
Add 'Table.row_from_mapping' helper. (googleapis#3425)
80028a5
@lukesneeringer lukesneeringer mentioned this pull request Aug 24, 2017
Bump BigQuery to 0.27.0 #3874
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@theacodes theacodes Awaiting requested review from theacodes
1 more reviewer
@dhermes dhermes dhermes left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: bigquery Issues related to the BigQuery API. cla: yes This human has signed the Contributor License Agreement. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@tseaver @lukesneeringer @dhermes @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.