Python Google Biq查询某物返回空/无行
使用PythonAPI查询大查询有时会返回无响应或无行。尽管再次重试相同的查询也可以。原因是什么Python Google Biq查询某物返回空/无行,python,google-app-engine,google-api,google-bigquery,Python,Google App Engine,Google Api,Google Bigquery,使用PythonAPI查询大查询有时会返回无响应或无行。尽管再次重试相同的查询也可以。原因是什么 def execute(self,bq_query,query_type,uid): self.cache = cache.Cache() cached_response = self.cache.get(bq_query) if(cached_response is not None): query_response = json.loads(zlib.d
def execute(self,bq_query,query_type,uid):
self.cache = cache.Cache()
cached_response = self.cache.get(bq_query)
if(cached_response is not None):
query_response = json.loads(zlib.decompress(cached_response))
app.logger.info("cached")
else:
big_query=_BigQuery(uid)
query_response = big_query.run_in_big_query(bq_query)
if not query_response:
logging.warning('**************************1.No reponse')
abort(404)
elif 'rows' not in query_response.keys():
logging.warning('**************************2.No rows')
abort(404)
def run_in_big_query(self, sql):
start = time.time()
queryData = {'query': sql}
queryRequest = self.service.jobs()
queryResponse = queryRequest.query(projectId=project_id,
body=queryData).execute()
app.logger.info('Query Time %f' % (time.time() - start))
return queryResponse
query方法将查询作业插入到BigQuery中。默认情况下,查询方法以
10s
for运行。指定非零超时值时,作业将等待结果,并在超时时引发异常
阅读更多关于
- 同步查询
- 异步查询