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: query_parameters fails if None is bound as parameter #9027

Closed
peku33 opened this issue Aug 14, 2019 · 1 comment · Fixed by #9029
Closed

BigQuery: query_parameters fails if None is bound as parameter #9027

peku33 opened this issue Aug 14, 2019 · 1 comment · Fixed by #9029
Assignees
Labels
api: bigquery Issues related to the BigQuery API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@peku33
Copy link

peku33 commented Aug 14, 2019

OS Type & Version: Ubuntu 19.04 x64
Python version: Python 3.7.3
Packges: latest up to this date:

'google-cloud-bigquery==1.18.0',

Steps to reproduce

  1. Create a query, bind None (NULL) as parameter
  2. Execute it
  3. Call query_parameters

Code example

from google.cloud import bigquery

client = bigquery.Client.from_service_account_json(
    <...>
)
job = client.query(
    "SELECT LOWER(@none_value)",
    job_config=bigquery.QueryJobConfig(
        query_parameters=[
            bigquery.ScalarQueryParameter('none_value', 'STRING', None)
        ]
    )
)
result = list(job.result())
query_parameters = job.query_parameters

Stack trace

Traceback (most recent call last):
  File "test.py", line 16, in <module>
    query_parameters = job.query_parameters
  File "/test/venv/lib/python3.7/site-packages/google/cloud/bigquery/job.py", line 2472, in query_parameters
    return self._configuration.query_parameters
  File "/test/venv/lib/python3.7/site-packages/google/cloud/bigquery/job.py", line 2200, in query_parameters
    return _from_api_repr_query_parameters(prop)
  File "/test/venv/lib/python3.7/site-packages/google/cloud/bigquery/job.py", line 1965, in _from_api_repr_query_parameters
    return [_query_param_from_api_repr(mapping) for mapping in resource]
  File "/test/venv/lib/python3.7/site-packages/google/cloud/bigquery/job.py", line 1965, in <listcomp>
    return [_query_param_from_api_repr(mapping) for mapping in resource]
  File "/test/venv/lib/python3.7/site-packages/google/cloud/bigquery/query.py", line 625, in _query_param_from_api_repr
    return klass.from_api_repr(resource)
  File "/test/venv/lib/python3.7/site-packages/google/cloud/bigquery/query.py", line 129, in from_api_repr
    value = resource["parameterValue"]["value"]
KeyError: 'parameterValue'

This is related to #7309

@plamut plamut added the api: bigquery Issues related to the BigQuery API. label Aug 14, 2019
@plamut
Copy link
Contributor

plamut commented Aug 14, 2019

I can confirm this, reproduced the issue with bigquery version 1.18.0.

@plamut plamut added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Aug 14, 2019
@plamut plamut self-assigned this Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants