Search code examples
pythongoogle-bigqueryiterator

Google Bigquery - Iterator has already started


Getting the error "Iterator already started" when using the results of a Bigquery with Python and would appreciate some help.

query_job_doi = client.query(config_doi_sql).result()
query_job_articles = client.query(topic_articles_sql).result()


for row in query_job_doi:
   for row_a in query_job_articles:
      if row[0]==row_a[0]:
        print("Success")
      else:
        print("DOI Miss match")

While running the code in the VM instance, it's giving the error -

('Iterator has already started', <google.cloud.bigquery.table.RowIterator object at 0x7fd82fe88150>)


Solution

  • Can you try this:

    query_job_doi = list(client.query(config_doi_sql).result())
    query_job_articles = list(client.query(topic_articles_sql).result())
    
    for row in query_job_doi:
       for row_a in query_job_articles:
          if row[0]==row_a[0]:
            print("Success")
          else:
            print("DOI Miss match")