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

前端 未结 1 1457
一个人的身影
一个人的身影 2021-01-13 06:20

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(

1条回答
  •  别那么骄傲
    2021-01-13 06:47

    Looks like you are right! The code no longer return these 3 parameters.

    As you can see in this commit from the public repository, fetch_data now returns an instance of the HTTPIterator class (guess I didn't realize this before as I have a docker image with an older version of the bigquery client installed where it does return the 3 values).

    The only way that I found to return the results was doing something like this:

    iterator = job_results.fetch_data()
    data = []
    for page in iterator._page_iter(False):
        data.extend([page.next() for i in range(page.num_items)])
    

    Notice that now we don't have to manage pageTokens anymore, it's been automated for the most part.

    [EDIT]:

    I just realized you can get results by doing:

    results = list(job_results.fetch_data())
    

    Got to admit it's way easier now then it was before!

    0 讨论(0)
提交回复
热议问题