【发布时间】:2017-07-04 01:54:05
【问题描述】:
我正在使用 BigQuery 客户端 API 编写 Python 代码,并尝试使用异步查询代码(作为代码示例随处编写),但在 fetch_data() 方法调用时失败。 Python 报错并报错:
ValueError:解包的值太多
因此,3 个返回值(rows、total_count、page_token)似乎是不正确的返回值数量。但是,除了仅显示这 3 个返回结果的众多代码示例之外,我找不到任何关于此方法应该返回什么的文档。
这是一段代码,显示了我在做什么(不包括“客户端”变量的初始化或导入的库,它们在我的代码中较早发生)。
#---> 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
我应该期望从异步查询作业的 job_results.fetch_data(...) 方法调用中得到什么具体的返回结果?
【问题讨论】:
-
为了调试,如果你打印结果,输出是什么,例如
result = job_results.fetch_data(max_results=10, page_token=page_token); print result?
标签: python asynchronous google-bigquery