给定一个查询示例,例如
import uuid
from google.cloud import bigquery
def query_shakespeare():
client = bigquery.Client()
query_job = client.run_async_query(str(uuid.uuid4()), """
#standardSQL
SELECT corpus AS title, COUNT(*) AS unique_words
FROM `publicdata.samples.shakespeare`
GROUP BY title
ORDER BY unique_words DESC
LIMIT 10""")
query_job.begin()
query_job.result() # Wait for job to complete.
destination_table = query_job.destination
destination_table.reload()
for row in destination_table.fetch_data():
print(row)
if __name__ == '__main__':
query_shakespeare()
如何获取表的架构?行,在前面的示例中具有形式
Row(('august', -1, 'aaa', 333), {'col1': 0, 'col2': 1, 'col3': 2})
但我找不到,对于包 google-cloud-bigquery==0.28.0 提取标头 JSON 的方式。当然,表模式的提取对我来说也很好,但当前的谷歌文档看起来不适用于最后一个版本......