-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
See documentation for structs in query parameters:
https://cloud.google.com/bigquery/querying-data#using_structs_in_parameterized_queries
- Stacktrace
$ python sync_query_params.py struct 7 hello
Traceback (most recent call last):
File "sync_query_params.py", line 204, in <module>
sync_query_struct_params(args.x, args.y)
File "sync_query_params.py", line 139, in sync_query_struct_params
query_results.run()
File "/Users/swast/src/google-cloud-python/bigquery/google/cloud/bigquery/query.py", line 360, in run
method='POST', path=path, data=self._build_resource())
File "/Users/swast/venvs/bq-dml/lib/python3.5/site-packages/google/cloud/_http.py", line 335, in api_request
error_info=method + ' ' + url)
google.cloud.exceptions.BadRequest: 400 Invalid query parameter type (POST https://www.googleapis.com/bigquery/v2/projects/cloud-samples-tests/queries)
- Code sample
The google-cloud-bigquery library produces a resource that looks like:
{
'name': 'struct_value',
'parameterValue': {
'structValues': {'y': 'hello', 'x': '7'}
},
'parameterType': {
'structTypes': [{'type': 'INT64', 'name': 'x'}, {'type': 'STRING', 'name': 'y'}]
}
}
The API expects a resource that looks like:
{
"name": "struct_value",
"parameterType": {
"type": "STRUCT",
"structTypes": [
{
"name": "x",
"type": {
"type": "INT64"
}
},
{
"name": "y",
"type": {
"type": "STRING"
}
}
]
},
"parameterValue": {
"structValues": {
"x": {
"value": "1"
},
"y": {
"value": "foo"
}
}
}
}
Notice the missing { "value": "my-value" } in the structValues in the request object produced by this library.
Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.