File tree 2 files changed +17
-3
lines changed
google/cloud/bigquery/job
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -1532,8 +1532,9 @@ def result( # type: ignore # (incompatible with supertype)
1532
1532
# Setting max_results should be equivalent to setting page_size with
1533
1533
# regards to allowing the user to tune how many results to download
1534
1534
# 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 :
1537
1538
page_size = max_results
1538
1539
1539
1540
# When timeout has default sentinel value ``object()``, do not pass
Original file line number Diff line number Diff line change @@ -1652,7 +1652,17 @@ def test_result_with_start_index(self):
1652
1652
1653
1653
start_index = 1
1654
1654
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
+ )
1656
1666
1657
1667
self .assertIsInstance (result , RowIterator )
1658
1668
self .assertEqual (result .total_rows , 5 )
@@ -1665,6 +1675,9 @@ def test_result_with_start_index(self):
1665
1675
self .assertEqual (
1666
1676
tabledata_list_request [1 ]["query_params" ]["startIndex" ], start_index
1667
1677
)
1678
+ self .assertEqual (
1679
+ tabledata_list_request [1 ]["query_params" ]["maxResults" ], page_size
1680
+ )
1668
1681
1669
1682
def test_result_error (self ):
1670
1683
from google .cloud import exceptions
You can’t perform that action at this time.
0 commit comments