Skip to content

Commit 337bf6e

Browse files
committed
Merge pull request #76 from BendingSpoons/master
Take into account limit argument when returning rows
2 parents a4461c1 + d454a3d commit 337bf6e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bigquery/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,13 @@ def get_query_rows(self, job_id, offset=None, limit=None, timeout=0):
327327
records = [self._transform_row(row, schema) for row in rows]
328328

329329
# Append to records if there are multiple pages for query results
330-
while page_token:
330+
while page_token and (not limit or len(records) < limit):
331331
query_reply = self.get_query_results(job_id, offset=offset, limit=limit,
332332
page_token=page_token, timeout=timeout)
333333
page_token = query_reply.get("pageToken")
334334
rows = query_reply.get('rows', [])
335335
records += [self._transform_row(row, schema) for row in rows]
336-
return records
336+
return records[:limit] if limit else records
337337

338338
def check_dataset(self, dataset_id):
339339
"""Check to see if a dataset exists.

0 commit comments

Comments
 (0)