fix: add warning when encountering unknown field types #1989
fix: add warning when encountering unknown field types #1989Linchin merged 15 commits intogoogleapis:mainfrom
Conversation
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.
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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
Got it. Yeah looks like
and 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.add warning for write and warn about future behavior changes
|
|
||
| def _field_from_json(resource, field): | ||
| converter = _CELLDATA_FROM_JSON.get(field.field_type, lambda value, _: value) | ||
| def default_converter(value, field): |
There was a problem hiding this comment.
Maybe we can move this function to outside, so we can reuse it for _scalar_field_to_json() as well?
There was a problem hiding this comment.
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.
|
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. |
Fixes #1988