`/projects/{projectId}/queries/{jobId}` endpoint does not respect the `maxResults` query parameter
ohaibbq opened this issue · comments
Dan Hansen commented
What happened?
When requesting with ?maxResults=0
, results are still included.
What did you expect to happen?
Query results should be limited to maxResults
in the response
How can we reproduce it (as minimally and precisely as possible)?
POST /projects/{projectId}/jobs
with a QueryJob
GET /project/{projectId}/jobs/{jobId}?maxResults=0
Anything else we need to know?
This raises an error in the Python BigQuery library when querying timestamps. The library doesn't expect data for this initial request so it doesn't send the formatOptions.useInt64Timestamp
parameter. It sends the format option on subsequent paged requests.
client = bigquery.Client("...")
results = client.query("SELECT TIMESTAMP '0001-01-01 00:00:00.000000+00', TIMESTAMP '9999-12-31 23:59:59.999999+00'")
for result in results:
print(result)
../../../../.local/lib/python3.11/site-packages/google/api_core/page_iterator.py:209: in _items_iter
for item in page:
../../../../.local/lib/python3.11/site-packages/google/api_core/page_iterator.py:131: in __next__
result = self._item_to_value(self._parent, item)
../../../../.local/lib/python3.11/site-packages/google/cloud/bigquery/table.py:3106: in _item_to_row
_helpers._row_tuple_from_json(resource, iterator.schema),
../../../../.local/lib/python3.11/site-packages/google/cloud/bigquery/_helpers.py:310: in _row_tuple_from_json
row_data.append(_field_from_json(cell["v"], field))
../../../../.local/lib/python3.11/site-packages/google/cloud/bigquery/_helpers.py:286: in _field_from_json
return converter(resource, field)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
value = '-62135596800.0'
field = SchemaField('$col1', 'TIMESTAMP', 'NULLABLE', None, None, (), None)
def _timestamp_from_json(value, field):
"""Coerce 'value' to a datetime, if set or not nullable."""
if _not_null(value, field):
# value will be a integer in seconds, to microsecond precision, in UTC.
> return _datetime_from_microseconds(int(value))
E ValueError: invalid literal for int() with base 10: '-62135596800.0'