【问题标题】:How to set BigQuery configuration properties with google-api-python-client?如何使用 google-api-python-client 设置 BigQuery 配置属性?
【发布时间】:2018-03-06 22:01:19
【问题描述】:
【问题讨论】:
-
也许这个example 就是你要找的东西,只需将查询优先级字段添加到字典定义中,它应该可以工作。
标签:
python
google-bigquery
google-api-python-client
【解决方案1】:
答案是使用jobs().insert() 而不是jobs().query()。异步插入新作业使调用者能够指定范围广泛的选项,但需要他们运行另一个命令才能获得结果。
所以假设gs 是您经过身份验证的服务对象:
# insert an asynchronous job
jobr = gs.jobs().insert(projectId='abc-123', body={'configuration':{'query':{'query':'SELECT COUNT(*) FROM schema.table'}}}).execute()
# get query results of job
gs.jobs().getQueryResults(projectId='abc-123', jobId=jobr['jobReference']['jobId']).execute()