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

/projects/{projectId}/queries/{jobId} endpoint does not respect the maxResults query parameter #262

Open
ohaibbq opened this issue Jan 25, 2024 · 0 comments · May be fixed by #263
Open
Labels
bug Something isn't working

Comments

@ohaibbq
Copy link
Contributor

ohaibbq commented Jan 25, 2024

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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant