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 — fix: add warning when encountering unknown field types by suzmue · Pull Request #1989 · googleapis/python-bigquery

This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Conversation

@suzmue

@suzmue suzmue commented Aug 5, 2024

Copy link
Copy Markdown
Contributor

Fixes #1988

Sorry, something went wrong.

Uh oh!

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

All reactions
suzmue added 8 commits August 2, 2024 15:51
@suzmue
fix: add warning when encountering unknown field types
a3efe4a
The types returned for currently unsupported field types may change
in the future, when support is added. Warn users that the types they
are using are not yet supported.
@suzmue
fix: add warning for unknown subfield types as well
fa8329f
@suzmue
fix: remove unused warnings
f382169
@suzmue
fix: remove leftover debugging code
f4e006f
@suzmue
move test case closer to related test
83ee4aa
@suzmue
add comments
d1d1eb4
@suzmue
fix formatting
a379e7b
@suzmue
fix test_table and use warnings.warn instead of pytest.warn
93dda16
@suzmue
suzmue requested review from a team and tswast August 5, 2024 21:14
@blunderbuss-gcf blunderbuss-gcf Bot assigned Linchin Aug 5, 2024
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery API. labels Aug 5, 2024
tswast
tswast reviewed Aug 5, 2024
View reviewed changes
Comment thread google/cloud/bigquery/_helpers.py Outdated
converter = _CELLDATA_FROM_JSON.get(field.field_type, lambda value, _: value)
def default_converter(value, field):
warnings.warn(
"Unknown type '{}' for field '{}'.".format(field.field_type, field.name),

@tswast tswast Aug 5, 2024

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.

Let's be explicit and say "Behavior reading this type is not officially supported and may change in future." or something scary along those lines.

Sorry, something went wrong.

Uh oh!

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

All reactions

@tswast tswast Aug 5, 2024

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.

Before we mark this as "fixed", I think the inverse direction is needed too (where we write JSON from a record), which is used in methods like client.insert_rows() (though maybe that already fails when encountering unknown types?)

Sorry, something went wrong.

Uh oh!

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

All reactions

@suzmue suzmue Aug 5, 2024

Copy link
Copy Markdown
Contributor Author

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.

Got it. Yeah looks like

python-bigquery/google/cloud/bigquery/_helpers.py

Line 690 in 4383cfe

# Unknown fields should not be silently dropped, include them. Since there
and

python-bigquery/google/cloud/bigquery/_helpers.py

Line 624 in 4383cfe

converter = _SCALAR_VALUE_TO_JSON_ROW.get(field.field_type)
are two points. The first there is no type info so probably just _scalar_field_to_json needs to be updated. Updated PR to include a warning for the write.

Sorry, something went wrong.

Uh oh!

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

All reactions
@suzmue
add explicit warning about behavior subject to change in the future
2be2830
add warning for write and warn about future behavior changes
Linchin
Linchin reviewed Aug 6, 2024
View reviewed changes
Comment thread google/cloud/bigquery/_helpers.py

def _field_from_json(resource, field):
converter = _CELLDATA_FROM_JSON.get(field.field_type, lambda value, _: value)
def default_converter(value, field):

@Linchin Linchin Aug 6, 2024

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.

Maybe we can move this function to outside, so we can reuse it for _scalar_field_to_json() as well?

Sorry, something went wrong.

Uh oh!

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

All reactions

@suzmue suzmue Aug 7, 2024

Copy link
Copy Markdown
Contributor Author

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 ended up just moving the warning itself to a new function, since the converter in _scalar_field_to_json has a different function signature.

Sorry, something went wrong.

Uh oh!

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

All reactions
suzmue and others added 5 commits August 7, 2024 08:24
@suzmue
add default converter for _SCALAR_VALUE_TO_JSON_PARAM
094e7dc
@suzmue
factor out shared warning
f29bb05
@suzmue
fix test case and make coverage happy
c0b6272
@suzmue
add unit test to StructQueryParameter class
be54ee5
@Linchin
Merge branch 'main' into warnConversion
a253165
@Linchin
Linchin self-requested a review August 12, 2024 22:21
@Linchin
Merge branch 'main' into warnConversion
cce5596
@Linchin Linchin added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 13, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 13, 2024
@Linchin

Linchin commented Aug 13, 2024

Copy link
Copy Markdown
Contributor

I think the docs test isn't failing due to changes in this PR, it appears to relate to the docker image used. I will approve this PR and force merge.

LGTM.

All reactions

Sorry, something went wrong.

Uh oh!

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

Linchin
Linchin approved these changes Aug 13, 2024
View reviewed changes
@Linchin
Linchin merged commit 8f5a41d into googleapis:main Aug 13, 2024
@release-please release-please Bot mentioned this pull request Aug 13, 2024
chore(main): release 3.26.0 #1973
Merged
This was referenced Oct 1, 2024
September 30, 2024 kitta65/bq-extension-vscode#536
Closed
September 30, 2024 kitta65/prettier-plugin-bq#500
Closed
September 30, 2024 kitta65/bq2cst#429
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@tswast tswast tswast left review comments
@Linchin Linchin Linchin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@Linchin Linchin

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: m Pull request size is medium.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add a warning in the type mapping if no conversion function is found

Uh oh!

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

4 participants

@suzmue @Linchin @tswast @yoshi-kokoro
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.