我每天都在BigQuery上用餐.如何查询“最新"消息?一? [英] I have daily tables on BigQuery. How to query the "newest" one?
问题描述
我创建每日表格.如何查询最新"的?
I create daily tables. How to query the "newest" one?
例如,GitHubArchive现在发布每日表格-而不是整体表格(请参阅 /r/bigquery/.../github_archive_changes_monthly_and_daily_tables/).
For example GitHubArchive now publishes daily tables - instead of a monolithic one (see /r/bigquery/.../github_archive_changes_monthly_and_daily_tables/).
推荐答案
要查找最新表,可以使用BigQuery的表查询功能:
To find the latest table, you could use BigQuery's table query functions:
例如,最新的每日GitHub存档表:
For example, the latest daily GitHubArchive table:
SELECT COUNT(*) num_records
FROM TABLE_QUERY(githubarchive:day,
"table_id IN (
SELECT table_id FROM githubarchive:day.__TABLES__
ORDER BY creation_time DESC LIMIT 1)")
# 201859
为了最大的方便,您可以将该查询存储为视图以与他人共享.然后要查询最新的表,只需查询视图:
For maximum convenience, you can store that query as a view to share with others. Then to query the latest table, just query the view:
SELECT num_records
FROM [fh-bigquery:public_dump.githubarchive_latest_day]
# 201859
For more on table query functions, see Jordan's answer to How do I use the TABLE_QUERY() function in BigQuery?.
这篇关于我每天都在BigQuery上用餐.如何查询“最新"消息?一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!