From 01b429d82f2caa5e53df5f39ed06f48ebc558be0 Mon Sep 17 00:00:00 2001 From: Chris Grinolds Date: Tue, 23 Dec 2014 11:44:17 -0800 Subject: [PATCH 1/2] Check whether GBQ Job is finished jobComplete can be False in query_reply. Simply checking for the existence of the field isn't enough, as a False value will cause a KeyError when checking for query_reply['totalRows'] --- pandas/io/gbq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/gbq.py b/pandas/io/gbq.py index 572a8be5c65e8..ce92a3dbfca40 100644 --- a/pandas/io/gbq.py +++ b/pandas/io/gbq.py @@ -185,7 +185,7 @@ def run_query(self, query): job_reference = query_reply['jobReference'] - while(not 'jobComplete' in query_reply): + while(not 'jobComplete' in query_reply) or (query_reply['jobComplete'] is False): print('Job not yet complete...') query_reply = job_collection.getQueryResults( projectId=job_reference['projectId'], From cf9fa0995ab7e0d6edf50f4dfd2421faeee9dfc6 Mon Sep 17 00:00:00 2001 From: cgrin Date: Tue, 23 Dec 2014 23:20:59 -0800 Subject: [PATCH 2/2] Verify GBQ job has completed --- pandas/io/gbq.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/gbq.py b/pandas/io/gbq.py index ce92a3dbfca40..91ec4831b0472 100644 --- a/pandas/io/gbq.py +++ b/pandas/io/gbq.py @@ -185,7 +185,8 @@ def run_query(self, query): job_reference = query_reply['jobReference'] - while(not 'jobComplete' in query_reply) or (query_reply['jobComplete'] is False): + # Verify the job has finished running + while(not query_reply.get('jobComplete', False)): print('Job not yet complete...') query_reply = job_collection.getQueryResults( projectId=job_reference['projectId'],