Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7d0fcee

Browse filesBrowse files
authored
fix: do not overwrite page_size with max_results when start_index is set (#1956)
* fix: do not overwrite page_size with max_results when start_index is set * update test
1 parent 7e522ee commit 7d0fcee
Copy full SHA for 7d0fcee

File tree

Expand file treeCollapse file tree

2 files changed

+17
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-3
lines changed

‎google/cloud/bigquery/job/query.py

Copy file name to clipboardExpand all lines: google/cloud/bigquery/job/query.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,8 +1532,9 @@ def result( # type: ignore # (incompatible with supertype)
15321532
# Setting max_results should be equivalent to setting page_size with
15331533
# regards to allowing the user to tune how many results to download
15341534
# while we wait for the query to finish. See internal issue:
1535-
# 344008814.
1536-
if page_size is None and max_results is not None:
1535+
# 344008814. But if start_index is set, user is trying to access a
1536+
# specific page, so we don't need to set page_size. See issue #1950.
1537+
if page_size is None and max_results is not None and start_index is None:
15371538
page_size = max_results
15381539

15391540
# When timeout has default sentinel value ``object()``, do not pass

‎tests/unit/job/test_query.py

Copy file name to clipboardExpand all lines: tests/unit/job/test_query.py
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,17 @@ def test_result_with_start_index(self):
16521652

16531653
start_index = 1
16541654

1655-
result = job.result(start_index=start_index)
1655+
# Verifies that page_size isn't overwritten by max_results when
1656+
# start_index is not None. See
1657+
# https://github.com/googleapis/python-bigquery/issues/1950
1658+
page_size = 10
1659+
max_results = 100
1660+
1661+
result = job.result(
1662+
page_size=page_size,
1663+
max_results=max_results,
1664+
start_index=start_index,
1665+
)
16561666

16571667
self.assertIsInstance(result, RowIterator)
16581668
self.assertEqual(result.total_rows, 5)
@@ -1665,6 +1675,9 @@ def test_result_with_start_index(self):
16651675
self.assertEqual(
16661676
tabledata_list_request[1]["query_params"]["startIndex"], start_index
16671677
)
1678+
self.assertEqual(
1679+
tabledata_list_request[1]["query_params"]["maxResults"], page_size
1680+
)
16681681

16691682
def test_result_error(self):
16701683
from google.cloud import exceptions

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.