Skip to content

fix: Job result returns proper page when start_index and page_size are not null #2046

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions google/cloud/bigquery/job/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,15 @@ def result( # type: ignore # (incompatible with supertype)
if page_size is None and max_results is not None and start_index is None:
page_size = max_results

# The api is insensitive to start_index when page_size is set. See
# github issue #1569. This is a patch to produce the exepected behavior.
if start_index is not None and page_size is not None:
if max_results is not None:
max_results = min(max_results, page_size)
else:
max_results = page_size
page_size = None

# When timeout has default sentinel value ``object()``, do not pass
# anything to invoke default timeouts in subsequent calls.
done_kwargs: Dict[str, Union[_helpers.TimeoutType, object]] = {}
Expand Down