BigQuery async query job - the fetch_results() method returns wrong number of values

Viewed 1789

I am writing Python code with the BigQuery Client API, and attempting to use the async query code (written everywhere as a code sample), and it is failing at the fetch_data() method call. Python errors out with the error:

ValueError: too many values to unpack

So, the 3 return values (rows, total_count, page_token) seem to be the incorrect number of return values. But, I cannot find any documentation about what this method is supposed to return -- besides the numerous code examples that only show these 3 return results.

Here is a snippet of code that shows what I'm doing (not including the initialization of the 'client' variable or the imported libraries, which happen earlier in my code).

#---> Set up and start the async query job
job_id = str(uuid.uuid4())
job = client.run_async_query(job_id, query)
job.destination = temp_tbl
job.write_disposition = 'WRITE_TRUNCATE'
job.begin()
print 'job started...'

#---> Monitor the job for completion
retry_count = 360
while retry_count > 0 and job.state != 'DONE':
    print 'waiting for job to complete...'
    retry_count -= 1
    time.sleep(1)
    job.reload()


if job.state == 'DONE':
     print 'job DONE.'
     page_token = None
     total_count = None
     rownum = 0
     job_results = job.results()

     while True:

         # ---- Next line of code errors out...
         rows, total_count, page_token = job_results.fetch_data( max_results=10, page_token=page_token )

         for row in rows:
             rownum += 1
             print "Row number %d" % rownum

             if page_token is None:
                 print 'end of batch.'
                 break

What are the specific return results I should expect from the job_results.fetch_data(...) method call on an async query job?

1 Answers
Related