【发布时间】:2021-04-10 07:22:09
【问题描述】:
我正在尝试创建一个从 bigquery 获取数据的云函数。该代码在 Jupyter 上运行良好,但在 Cloud Function 上无法运行。
from google.cloud import bigquery
def main(request):
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] ='xxxx.json'
bigquery_client = bigquery.Client(project='xxxx')
query = """select scavenger_hunt_mode_time_spent_minutes, explore_mode_time_spent_minutes,
browsemode_time_spent_minutes, nationalpark_time_spend_minutes, explore_marker_tracked_ids,
browsemode_content_clicked_models_ids,browsemode_content_clicked_maps, national_park_lifetime_scenarios_solved,
scavenger_hunt_mode_session_story_ids_completed, time from `plugo-244108.mix.new_tableau_orboot*` where Email='xxx.com' and orbootername='xxxx'"""
query_job = bigquery_client.query(query)
geography = query_job.to_dataframe()
return len(geography)
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a int.
【问题讨论】:
标签: python api google-bigquery google-cloud-functions