Skip to content
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

Bigquery API: query_response_to_dict raises exception for nullable values. #577

Open
alex-kowalczyk opened this issue Jan 21, 2023 · 0 comments

Comments

@alex-kowalczyk
Copy link

The following exception is raised by gcloud.aio.bigquery.query_response_to_dict for a nullable integer field with:

  • schema {'name': 'fieldName', 'type': 'INTEGER', 'mode': 'NULLABLE'}
  • received value {'v': None}:
    items = query_response_to_dict(query_resp)
  File "gcloud/aio/bigquery/utils.py", line 142, in query_response_to_dict
    return [
  File "gcloud/aio/bigquery/utils.py", line 143, in <listcomp>
    {k['name']: parse(k, v) for k, v in zip(fields, row)}
  File "gcloud/aio/bigquery/utils.py", line 143, in <dictcomp>
    {k['name']: parse(k, v) for k, v in zip(fields, row)}
  File "gcloud/aio/bigquery/utils.py", line 126, in parse
    return convert(flatten(value))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

I think this check in parse function (107-108) is incorrect

    if field['mode'] == 'NULLABLE' and value is None:
        return value

It should be something like ... and flatten(value) is None:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant