【发布时间】:2018-06-30 01:06:48
【问题描述】:
from google.cloud import bigquery
import datalab.bigquery as bq
query_job = client.run_sync_query("""
SELECT
CONCAT(
'https://stackoverflow.com/questions/',
CAST(id as STRING)) as url,
view_count
FROM `bigquery-public-data.stackoverflow.posts_questions`
WHERE tags like '%google-bigquery%'
ORDER BY view_count DESC
LIMIT 10""")
results = query_job.result() # Waits for job to complete.
for row in results:
print("{}".format(row.start_time))
我尝试在 jupyter notebook 中运行以上代码,但系统给出“AttributeError: 'QueryResults' object has no attribute 'result'”
我找不到替换结果对象的文档。
(现有文档 https://cloud.google.com/bigquery/create-simple-app-api 已过时,因为 run_sync_query 也正在替换 run_query) 你能帮帮我吗?
【问题讨论】:
-
尝试使用来自googlecloudplatform.github.io/google-cloud-python/latest/…的示例,但仍然遇到同样的错误
标签: sql google-bigquery jupyter-notebook